File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,16 @@ $.widget( "ui.mask", {
80
80
if ( begin !== undefined ) {
81
81
end = ( end === undefined ) ? begin : end ;
82
82
if ( dom . setSelectionRange ) {
83
- dom . setSelectionRange ( begin , end ) ;
83
+ /* Chrome fires off the focus events before positioning the
84
+ cursor based on where the user clicked. This is annoying
85
+ because, in the case of tyring to position the cursor at
86
+ the beginning of an empty input, the eventual positioning
87
+ based on the user's click overrides whatever we do here.
88
+ There's no good fix for this except to wait until the
89
+ click processesing resolves and _then_ reposition things. */
90
+ setTimeout ( function ( ) {
91
+ dom . setSelectionRange ( begin , end ) ;
92
+ } , /* yes, zero is long enough */ 0 ) ;
84
93
} else if ( dom . createTextRange ) {
85
94
range = dom . createTextRange ( ) ;
86
95
range . collapse ( true ) ;
You can’t perform that action at this time.
0 commit comments