[BUGFIX] Cursor position is changed while typing 37/47737/3
authorSascha Egerer <sascha@sascha-egerer.de>
Sun, 17 Apr 2016 20:38:48 +0000 (22:38 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Mon, 18 Apr 2016 20:54:44 +0000 (22:54 +0200)
Fields in the backend are validated while typing. One validation
is the left space trim. Spaces on the left side are removed but
also the cursor position is changed. If you are a fast typer
this could end up in a mixed up input. The cursor position should
not be changed by the validation JavaScript.

Change-Id: I93e46dff763363eed193d41b1fd71fbe043fbcd8
Resolves: #75724
Related: #75626
Releases: master
Reviewed-on: https://review.typo3.org/47737
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Resources/Public/JavaScript/FormEngineValidation.js

index ba6ba33..8408d90 100644 (file)
@@ -521,37 +521,13 @@ define(['jquery', 'TYPO3/CMS/Backend/FormEngine'], function ($, FormEngine) {
                                        modified = true;
                                }
                                if (modified) {
-                                       $field.attr('value', newValue);
-                                       FormEngineValidation.setCaretPosition($field, 0);
+                                       $field.val(newValue);
                                }
                        }
                });
        };
 
        /**
-        * Set the caret position in a text field
-        *
-        * @param {Object} $element
-        * @param {Number} caretPos
-        */
-       FormEngineValidation.setCaretPosition = function($element, caretPos) {
-               var elem = $element.get(0);
-
-               if (elem.createTextRange) {
-                       var range = elem.createTextRange();
-                       range.move('character', caretPos);
-                       range.select();
-               } else {
-                       if (elem.selectionStart) {
-                               elem.focus();
-                               elem.setSelectionRange(caretPos, caretPos);
-                       } else {
-                               elem.focus();
-                       }
-               }
-       };
-
-       /**
         * Helper function to get clean trimmed array from comma list
         *
         * @param {String} delimiter