fix(xo-web/modal): close modal when navigating to another url (#7301)

This commit is contained in:
OlivierFL
2024-01-16 20:47:21 +01:00
committed by GitHub
parent c81c23c0d0
commit 58769815b0
3 changed files with 13 additions and 0 deletions
+1
View File
@@ -27,6 +27,7 @@
- [REST API] Fix `/backup/log/<id>` which was broken by the `/backups` to `/backup` renaming [Forum#69426](https://xcp-ng.org/forum/post/69426) - [REST API] Fix `/backup/log/<id>` which was broken by the `/backups` to `/backup` renaming [Forum#69426](https://xcp-ng.org/forum/post/69426)
- [Backup/Restore] Fix unnecessary pool selector in XO config backup restore modal [Forum#8130](https://xcp-ng.org/forum/topic/8130/xo-configbackup-restore) (PR [#7287](https://github.com/vatesfr/xen-orchestra/pull/7287)) - [Backup/Restore] Fix unnecessary pool selector in XO config backup restore modal [Forum#8130](https://xcp-ng.org/forum/topic/8130/xo-configbackup-restore) (PR [#7287](https://github.com/vatesfr/xen-orchestra/pull/7287))
- [File restore] Fix potential race condition in partition mount/unmount (PR [#7312](https://github.com/vatesfr/xen-orchestra/pull/7312)) - [File restore] Fix potential race condition in partition mount/unmount (PR [#7312](https://github.com/vatesfr/xen-orchestra/pull/7312))
- [Modal] Fix opened modal not closing when navigating to another route/URL (PR [#7301](https://github.com/vatesfr/xen-orchestra/pull/7301))
### Packages to release ### Packages to release
+6
View File
@@ -378,6 +378,12 @@ export default class Modal extends Component {
this.state = { showModal: false } this.state = { showModal: false }
} }
static close() {
if (instance.state.showModal) {
instance.setState({ showModal: false })
}
}
componentDidMount() { componentDidMount() {
if (instance) { if (instance) {
throw new Error('Modal is a singleton!') throw new Error('Modal is a singleton!')
+6
View File
@@ -285,6 +285,12 @@ export default class XoApp extends Component {
} }
} }
componentDidUpdate(prev) {
if (prev.location.pathname !== this.props.location.pathname) {
Modal.close()
}
}
_shortcutsHandler = (command, event) => { _shortcutsHandler = (command, event) => {
event.preventDefault() event.preventDefault()
switch (command) { switch (command) {