From 6b00394d8564bf072bb9166497494bfcb1e1400f Mon Sep 17 00:00:00 2001 From: Markus Winter Date: Sun, 10 Sep 2023 12:01:04 +0100 Subject: [PATCH] Prevent scrolling for textarea preview (#8472) 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"; };