Skip to content

Commit

Permalink
Close all nested drawers when navigating
Browse files Browse the repository at this point in the history
  • Loading branch information
distantnative committed Mar 24, 2024
1 parent 674dd97 commit 3b1c42b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions panel/src/panel/drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,18 @@ export default (panel) => {
/**
* Closes the drawer and goes back to the
* parent one if it has been stored
* @param {String|true} id Which drawer to close, true for all
*/
async close(id) {
if (this.isOpen === false) {
return;
}

// Force close all drawers
if (id === true) {
this.history.clear();
}

// Compare the drawer id to avoid closing
// the wrong drawer. This is particularly useful
// in nested drawers.
Expand Down
3 changes: 3 additions & 0 deletions panel/src/panel/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export default () => {
at(index) {
return this.milestones.at(index);
},
clear() {
this.milestones = [];
},
get(id = null) {
if (id === null) {
return this.milestones;
Expand Down
3 changes: 2 additions & 1 deletion panel/src/panel/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,8 @@ export default {
// modals will be closed if the response is null or false.
// on undefined, the state of the modal stays untouched
else if (state[modal] !== undefined) {
this[modal].close();
// force close all nested modals
this[modal].close(true);
}
}

Expand Down

0 comments on commit 3b1c42b

Please sign in to comment.