Very experimental handle "back" to close media modal
Don't try this at home, kids
This commit is contained in:
parent
9822583048
commit
0f1b08b3ea
|
@ -22,6 +22,17 @@ function MediaModal({
|
|||
const carouselFocusItem = useRef(null);
|
||||
useLayoutEffect(() => {
|
||||
carouselFocusItem.current?.scrollIntoView();
|
||||
|
||||
history.pushState({ mediaModal: true }, '');
|
||||
const handlePopState = (e) => {
|
||||
if (e.state?.mediaModal) {
|
||||
onClose();
|
||||
}
|
||||
};
|
||||
window.addEventListener('popstate', handlePopState);
|
||||
return () => {
|
||||
window.removeEventListener('popstate', handlePopState);
|
||||
};
|
||||
}, []);
|
||||
const prevStatusID = useRef(statusID);
|
||||
useEffect(() => {
|
||||
|
|
Loading…
Reference in a new issue