fix(xo-web/modal): close modal when navigating to another url (#7301)
This commit is contained in:
@@ -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)
|
||||
- [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))
|
||||
- [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
|
||||
|
||||
|
||||
@@ -378,6 +378,12 @@ export default class Modal extends Component {
|
||||
this.state = { showModal: false }
|
||||
}
|
||||
|
||||
static close() {
|
||||
if (instance.state.showModal) {
|
||||
instance.setState({ showModal: false })
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
if (instance) {
|
||||
throw new Error('Modal is a singleton!')
|
||||
|
||||
@@ -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) => {
|
||||
event.preventDefault()
|
||||
switch (command) {
|
||||
|
||||
Reference in New Issue
Block a user