Skip to content

Commit

Permalink
Merge pull request #111 from BerkieBb/master
Browse files Browse the repository at this point in the history
fix(web/menu): force close menu when using the nui event
LukeWasTakenn authored Sep 30, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 6584105 + 16aeed6 commit 60c4e4e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions web/src/features/menu/list/index.tsx
Original file line number Diff line number Diff line change
@@ -37,8 +37,8 @@ const ListMenu: React.FC = () => {
const [indexStates, setIndexStates] = useState<Record<number, number>>({});
const listRefs = useRef<Array<HTMLDivElement | null>>([]);

const closeMenu = (ignoreFetch?: boolean, keyPressed?: string) => {
if (menu.canClose === false) return;
const closeMenu = (ignoreFetch?: boolean, keyPressed?: string, forceClose?: boolean) => {
if (menu.canClose === false && !forceClose) return;
setVisible(false);
if (!ignoreFetch) fetchNui('closeMenu', keyPressed);
};
@@ -119,7 +119,7 @@ const ListMenu: React.FC = () => {
return () => window.removeEventListener('keydown', keyHandler);
}, [visible]);

useNuiEvent('closeMenu', () => closeMenu(true));
useNuiEvent('closeMenu', () => closeMenu(true, undefined, true));

useNuiEvent('setMenu', (data: MenuSettings) => {
if (!data.startItemIndex || data.startItemIndex < 0) data.startItemIndex = 0;

0 comments on commit 60c4e4e

Please sign in to comment.