Skip to content

Commit 05f15a5

Browse files
SimeonCSimeonC
SimeonC
authored and
SimeonC
committed
fix(taBind): Fix cursor selection on focus
Fixes #444
1 parent dd479a1 commit 05f15a5

File tree

4 files changed

+37
-3
lines changed

4 files changed

+37
-3
lines changed

dist/textAngular.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/taBind.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -445,11 +445,16 @@ angular.module('textAngular.taBind', ['textAngular.factories', 'textAngular.DOM'
445445
ngModel.$render();
446446
});
447447

448+
element.on('mouseup', function(){
449+
var _selection = taSelection.getSelection();
450+
if(_selection.start.element === element[0]) taSelection.setSelectionToElementStart(element.children()[0]);
451+
});
452+
448453
// prevent propagation on mousedown in editor, see #206
449454
element.on('mousedown', function(event, eventData){
450455
/* istanbul ignore else: this is for catching the jqLite testing*/
451456
if(eventData) angular.extend(event, eventData);
452-
event.stopPropagation();
457+
event.stopPropagation();
453458
});
454459
}
455460
}

src/textAngular.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -1238,11 +1238,16 @@ angular.module('textAngular.taBind', ['textAngular.factories', 'textAngular.DOM'
12381238
ngModel.$render();
12391239
});
12401240

1241+
element.on('mouseup', function(){
1242+
var _selection = taSelection.getSelection();
1243+
if(_selection.start.element === element[0]) taSelection.setSelectionToElementStart(element.children()[0]);
1244+
});
1245+
12411246
// prevent propagation on mousedown in editor, see #206
12421247
element.on('mousedown', function(event, eventData){
12431248
/* istanbul ignore else: this is for catching the jqLite testing*/
12441249
if(eventData) angular.extend(event, eventData);
1245-
event.stopPropagation();
1250+
event.stopPropagation();
12461251
});
12471252
}
12481253
}

test/taBind/taBind.spec.js

+24
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)