Bug 21131: Remove the TinyMCE.isDirty() check that caused unexpected behaviour
authorDavid Cook <dcook@prosentient.com.au>
Mon, 30 Jul 2018 04:35:40 +0000 (14:35 +1000)
committerNick Clemens <nick@bywatersolutions.com>
Thu, 9 Aug 2018 11:11:22 +0000 (11:11 +0000)
When using the WYSIWYG editor for system preferences, the editor only
updates the textarea element if the content is different from the
original content. This means if you change a system preference and
then change it back to the original content, the textarea will have
the 2nd last change you made.

This patch removes the TinyMCE.isDirty() check, which was responsible
for comparing the original and changed content. Every input/keydown/dragend
or TinyMCE command will cause the textarea element to be updated and
trigger the input event which causes the "modified" class to be added
to the element, so that the system preference can be saved.

__TEST PLAN__

_Before applying_
0. Change "UseWYSIWYGinSystemPreferences" to "Show"
1. Change "opaccredits" to "123a"
2. Click "Save all OPAC preferences"
3. Reload the page
4. Change "opaccredits" to "123"
5. Change "opaccredits" to "123a"
6. Click "Save all OPAC preferences"
7. Reload the page
8. Note that "opaccredits" says "123"

_Apply the patch_

_After applying_
1. Change "opaccredits" to "123a"
2. Change "opaccredits" to "123"
3. Click "Save all OPAC preferences"
4. Reload the page
5. Note that "opaccredits" says "123" (and not "123a")
6. Change "opaccredits" to "1234"
7. Click "Save all OPAC preferences"
8. Reload the page
9. Note that "opaccredits" says "1234"

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
koha-tmpl/intranet-tmpl/prog/en/includes/wysiwyg-systempreferences.inc

index b2d3fe5..5dcd1cc 100644 (file)
@@ -31,17 +31,13 @@ tinyMCE.init({
             -%]
 
             tinyMCE.dom.Event.bind(editor.getBody(), 'input keyup dragend', function(e){
-                if (ed.isDirty()){
-                    wysiwyg_change(ed);
-                }
+                wysiwyg_change(ed);
             });
         });
 
         // Register change when TinyMCE command returns isDirty()
         ed.onExecCommand.add(function(ed, cmd, ui, val) {
-            if (ed.isDirty()){
-                wysiwyg_change(ed);
-            }
+            wysiwyg_change(ed);
         });
 
     },