mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 21:27:05 +00:00
Merge branch 'discover-filters' into inputs-modal
This commit is contained in:
commit
52fb392c2a
1 changed files with 1 additions and 12 deletions
|
|
@ -34,18 +34,9 @@ const ModalDialog = ({ className, title, buttons, children, dataset, onCloseRequ
|
|||
event.nativeEvent.closeModalDialogPrevented = true;
|
||||
}, []);
|
||||
React.useEffect(() => {
|
||||
const onWindowResize = (event) => {
|
||||
if (typeof onCloseRequest === 'function') {
|
||||
onCloseRequest({
|
||||
type: 'close',
|
||||
dataset: dataset,
|
||||
nativeEvent: event
|
||||
});
|
||||
}
|
||||
};
|
||||
const onWindowKeyDown = (event) => {
|
||||
// its `-2` because focus lock render locking divs around its content
|
||||
if (modalsContainer.childNodes[modalsContainer.childElementCount - 2] === modalContainerRef.current) {
|
||||
if (event.key === 'Escape' && modalsContainer.childNodes[modalsContainer.childElementCount - 2] === modalContainerRef.current) {
|
||||
if (typeof onCloseRequest === 'function') {
|
||||
onCloseRequest({
|
||||
type: 'close',
|
||||
|
|
@ -55,10 +46,8 @@ const ModalDialog = ({ className, title, buttons, children, dataset, onCloseRequ
|
|||
}
|
||||
}
|
||||
};
|
||||
window.addEventListener('resize', onWindowResize);
|
||||
window.addEventListener('keydown', onWindowKeyDown);
|
||||
return () => {
|
||||
window.removeEventListener('resize', onWindowResize);
|
||||
window.removeEventListener('keydown', onWindowKeyDown);
|
||||
};
|
||||
}, [dataset, onCloseRequest]);
|
||||
|
|
|
|||
Loading…
Reference in a new issue