From a0804ab44de353d196be3b4e21887532289cc168 Mon Sep 17 00:00:00 2001 From: Markus Winter Date: Fri, 8 Sep 2023 20:16:46 +0100 Subject: [PATCH] prevent scrolling for preview Prevent that when clicking on preview for a textarea, the page scrolls to the top and the url changed. --- core/src/main/resources/lib/form/textarea/textarea.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/main/resources/lib/form/textarea/textarea.js b/core/src/main/resources/lib/form/textarea/textarea.js index 7085ff2a0e84..1677e11fdd16 100644 --- a/core/src/main/resources/lib/form/textarea/textarea.js +++ b/core/src/main/resources/lib/form/textarea/textarea.js @@ -45,7 +45,8 @@ Behaviour.specify( hidePreview.style.display = "none"; previewDiv.style.display = "none"; - showPreview.onclick = function () { + showPreview.onclick = function (event) { + event.preventDefault(); // Several TEXTAREAs may exist if CodeMirror is enabled. The first one has reference to the CodeMirror object. var textarea = e.parentNode.getElementsByTagName("TEXTAREA")[0]; var text = ""; @@ -85,7 +86,8 @@ Behaviour.specify( }); }; - hidePreview.onclick = function () { + hidePreview.onclick = function (event) { + event.preventDefault(); hidePreview.style.display = "none"; previewDiv.style.display = "none"; };