You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** (Web) In order to mimic similar behavior to Android's back button to close the modal on mobile web, HistoryModal will use hash or query string to determine whether it is opened or not. @default false */
7
7
useHistory?: boolean;
8
-
/** (Web) Only works when `useHistory` is true. Hash string to append to location */
9
-
hash?: string|null;
10
-
/** (Web) Only works when `useHistory` is true. Same as hash, but using query string. Query string will take precedence over hash @default null */
// Close the modal if the history state no longer contains our modal name
62
+
if(
63
+
(!event.state||
64
+
!event.state.modal||
65
+
!event.state.modal[this.modalId])&&
66
+
onRequestClose
67
+
){
68
+
this.clearBrowserState();
39
69
onRequestClose();
40
70
}
71
+
72
+
// When the browser back button is pressed and uppy is now the latest entry in the history but the modal is closed, fix the history by removing the uppy history entry
73
+
// This occurs when another entry is added into the history state while the modal is open, and then the modal gets manually closed
Copy file name to clipboardExpand all lines: src/components/Modal/Modal.mdx
+46-7Lines changed: 46 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -83,20 +83,59 @@ import { Text } from '../Typography';
83
83
84
84
## Modal using browser history
85
85
86
-
Same as `Modal` below, with the difference that this uses `useHistory` prop that uses `hash` or `query-string` to determine visibility of the modal. The goal is to mimic Android's back button behavior on web which closes modals. On RN, this will have no effect and will use a regular `Modal`
86
+
By using `useHistory` prop it will mimic Android's back button behavior on web which closes modals. On RN, this will have no effect and will use a regular `Modal`. Works in nested modals as well.
87
+
88
+
Note: Uses history `state` to manipulate modal state
0 commit comments