Skip to content

Commit

Permalink
prevent scrolling for preview
Browse files Browse the repository at this point in the history
Prevent that when clicking on preview for a textarea, the page scrolls
to the top and the url changed.
  • Loading branch information
mawinter69 committed Sep 8, 2023
1 parent fb6a03c commit a0804ab
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 a0804ab

Please sign in to comment.