about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/features/ui/components/modal_root.js
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2021-07-12 17:55:40 +0200
committerClaire <claire.github-309c@sitedethib.com>2021-07-12 20:13:02 +0200
commit6e3d5cbca26995e99d6ca8b1e3191edc539d87eb (patch)
treede8d16f8084deffcda17c8a926a7ed07ef06be04 /app/javascript/flavours/glitch/features/ui/components/modal_root.js
parentc5b4e6b7084e8257979adec87f97d4800b7bec57 (diff)
Fix and simplify browser history handling in relation to modals
This simplifies the logic to:
- when the last modal gets closed and we're in our history buffer state, go back
- whenever a modal is open, ensure we're in a history buffer state by
  potentially pushing one
Diffstat (limited to 'app/javascript/flavours/glitch/features/ui/components/modal_root.js')
-rw-r--r--app/javascript/flavours/glitch/features/ui/components/modal_root.js8
1 files changed, 2 insertions, 6 deletions
diff --git a/app/javascript/flavours/glitch/features/ui/components/modal_root.js b/app/javascript/flavours/glitch/features/ui/components/modal_root.js
index 0fd70de34..2636e79f5 100644
--- a/app/javascript/flavours/glitch/features/ui/components/modal_root.js
+++ b/app/javascript/flavours/glitch/features/ui/components/modal_root.js
@@ -59,12 +59,8 @@ export default class ModalRoot extends React.PureComponent {
     backgroundColor: null,
   };
 
-  getSnapshotBeforeUpdate () {
-    return { visible: !!this.props.type };
-  }
-
-  componentDidUpdate (prevProps, prevState, { visible }) {
-    if (visible) {
+  componentDidUpdate () {
+    if (!!this.props.type) {
       document.body.classList.add('with-modals--active');
       document.documentElement.style.marginRight = `${getScrollbarWidth()}px`;
     } else {