[BUGFIX] Colorpicker in irre records 97/54797/2
authorFrank Naegler <frank.naegler@typo3.org>
Thu, 23 Nov 2017 16:04:16 +0000 (17:04 +0100)
committerFrank Naegler <frank.naegler@typo3.org>
Mon, 27 Nov 2017 18:27:07 +0000 (19:27 +0100)
This patch checks if a value is set before writing
a possbile empty value to the field.

Resolves: #83000
Releases: master, 8.7
Change-Id: I3badd9b9ff1a567351d971b5ae0199bf347e0f72
Reviewed-on: https://review.typo3.org/54797
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
typo3/sysext/backend/Resources/Private/TypeScript/ColorPicker.ts
typo3/sysext/backend/Resources/Public/JavaScript/ColorPicker.js

index efe5d1b..d214123 100644 (file)
@@ -41,13 +41,15 @@ class ColorPicker {
       position: 'bottom left',
       theme: 'bootstrap',
     });
-    (<any> $(document)).on('change', '.t3js-colorpicker-value-trigger', function(): void {
-      (<any> $(this))
-        .closest('.t3js-formengine-field-item')
-        .find('.t3js-color-picker')
-        .val(this.value)
-        .trigger('paste');
-      (<any> $(this)).val('');
+    $(document).on('change', '.t3js-colorpicker-value-trigger', (event: Event): void => {
+      const $element: any = $(event.target);
+      if ($element.val() !== '') {
+        $element.closest('.t3js-formengine-field-item')
+          .find('.t3js-color-picker')
+          .val($element.val())
+          .trigger('paste');
+        $element.val('');
+      }
     });
   }
 }
index 88a3a1a..6f027e8 100644 (file)
@@ -33,13 +33,15 @@ define(["require", "exports", "jquery", "TYPO3/CMS/Core/Contrib/jquery.minicolor
                 position: 'bottom left',
                 theme: 'bootstrap',
             });
-            $(document).on('change', '.t3js-colorpicker-value-trigger', function () {
-                $(this)
-                    .closest('.t3js-formengine-field-item')
-                    .find('.t3js-color-picker')
-                    .val(this.value)
-                    .trigger('paste');
-                $(this).val('');
+            $(document).on('change', '.t3js-colorpicker-value-trigger', function (event) {
+                var $element = $(event.target);
+                if ($element.val() !== '') {
+                    $element.closest('.t3js-formengine-field-item')
+                        .find('.t3js-color-picker')
+                        .val($element.val())
+                        .trigger('paste');
+                    $element.val('');
+                }
             });
         };
         return ColorPicker;