Skip to content

Commit

Permalink
Prevent scrolling for textarea preview (#8472)
Browse files Browse the repository at this point in the history
prevent scrolling for preview

Prevent that when clicking on preview for a textarea, the page scrolls
to the top and the url changed.
  • Loading branch information
mawinter69 authored Sep 10, 2023
1 parent 3059161 commit 6b00394
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/src/main/resources/lib/form/textarea/textarea.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand Down Expand Up @@ -85,7 +86,8 @@ Behaviour.specify(
});
};

hidePreview.onclick = function () {
hidePreview.onclick = function (event) {
event.preventDefault();
hidePreview.style.display = "none";
previewDiv.style.display = "none";
};
Expand Down

0 comments on commit 6b00394

Please sign in to comment.