mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 21:27:05 +00:00
refactor(MenuProvider): close menus on resize
This commit is contained in:
parent
c460a1edf7
commit
6470a06c57
1 changed files with 6 additions and 1 deletions
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright (C) 2017-2024 Smart code 203358507
|
||||
|
||||
import React, { useLayoutEffect, useMemo, useRef, useState } from 'react';
|
||||
import React, { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
import classNames from 'classnames';
|
||||
import useKeyboardEvent from '../useKeyboardEvent';
|
||||
|
|
@ -70,6 +70,11 @@ const MenuProvider = ({ children, className }: Props) => {
|
|||
}
|
||||
}, [active]);
|
||||
|
||||
useEffect(() => {
|
||||
window.addEventListener('resize', closeAll);
|
||||
return () => window.removeEventListener('resize', closeAll);
|
||||
});
|
||||
|
||||
useKeyboardEvent('Escape', closeAll);
|
||||
useOnClickOutside(container.current && active?.parent ? [container.current, active.parent] : [], closeAll);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue