mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-24 08:48:47 +01:00
Very experimental handle "back" to close media modal
Don't try this at home, kids
This commit is contained in:
parent
9822583048
commit
0f1b08b3ea
1 changed files with 11 additions and 0 deletions
|
@ -22,6 +22,17 @@ function MediaModal({
|
||||||
const carouselFocusItem = useRef(null);
|
const carouselFocusItem = useRef(null);
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
carouselFocusItem.current?.scrollIntoView();
|
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);
|
const prevStatusID = useRef(statusID);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
Loading…
Reference in a new issue