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", {
8080 if ( begin !== undefined ) {
8181 end = ( end === undefined ) ? begin : end ;
8282 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 ) ;
8493 } else if ( dom . createTextRange ) {
8594 range = dom . createTextRange ( ) ;
8695 range . collapse ( true ) ;
You can’t perform that action at this time.
0 commit comments