Skip to content

Commit 688f804

Browse files
committed
Merge remote-tracking branch 'tango/MAGETWO-99562' into PR-2.2-ALL
2 parents f48907e + 13590da commit 688f804

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/web/mage/trim-input.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,20 @@ define([
4141
* @private
4242
*/
4343
_trimInput: function () {
44-
var input = this._getInputValue().trim();
44+
// Safari caret position workaround: storing carter position
45+
var caretStart, caretEnd, input;
46+
47+
caretStart = this.options.cache.input.get(0).selectionStart;
48+
caretEnd = this.options.cache.input.get(0).selectionEnd;
49+
50+
input = this._getInputValue().trim();
4551

4652
this.options.cache.input.val(input);
53+
54+
// Safari caret position workaround: setting caret position to previously stored values
55+
if (caretStart !== null && caretEnd !== null) {
56+
this.options.cache.input.get(0).setSelectionRange(caretStart, caretEnd);
57+
}
4758
},
4859

4960
/**

0 commit comments

Comments
 (0)