Skip to content

Commit

Permalink
Merge pull request #4045 from GeotrekCE/fix_new_flatpages_open_in_sam…
Browse files Browse the repository at this point in the history
…e_tab

New menu items with page target open it in same tab
  • Loading branch information
marcantoinedupre committed Apr 4, 2024
2 parents 28fec19 + afe4177 commit fb42f7e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ CHANGELOG
2.104.1+dev (XXXX-XX-XX)
------------------------

**Bug fix**

- New menu items targeting static page now open it in the same tab


2.104.1 (2024-04-03)
Expand Down
6 changes: 6 additions & 0 deletions geotrek/flatpages/static/flatpages/js/menu_item_fieldsets.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ function cleanSubmission() {
});
};

let uncheckOpenInNewTab = function() {
let checkbox = document.querySelector("input[name=open_in_new_tab]");
checkbox.checked = false;
}

let erasePageField = function() {
let page_select = document.querySelector("select[name=\"page\"]");
page_select.value = undefined;
Expand All @@ -67,6 +72,7 @@ function cleanSubmission() {
let targetType = document.getElementById("id_target_type").value;
if (targetType === "page") {
eraseLinkUrlFields();
uncheckOpenInNewTab();
} else if (targetType === "link") {
erasePageField();
} else {
Expand Down

0 comments on commit fb42f7e

Please sign in to comment.