Skip to content

Commit

Permalink
fix(web/radial): check whether radial menu was closed during transition
Browse files Browse the repository at this point in the history
Closing the radial menu during the transition from the more pages would cause the menu to be stuck open
  • Loading branch information
LukeWasTakenn committed Feb 25, 2023
1 parent 709d512 commit 6e1a978
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
14 changes: 13 additions & 1 deletion resource/interface/client/radial.lua
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ RegisterNUICallback('radialBack', function(_, cb)

Wait(100)

-- If menu was closed during transition, don't open the submenu
if not isOpen then return end

SendNUIMessage({
action = 'openRadialMenu',
data = {
Expand All @@ -226,6 +229,15 @@ RegisterNUICallback('radialClose', function(_, cb)
currentRadial = nil
end)

RegisterNUICallback('radialTransition', function(_, cb)
Wait(100)

-- If menu was closed during transition, don't open the submenu
if not isOpen then return cb(false) end

cb(true)
end)

lib.addKeybind({
name = 'ox_lib-radial',
description = 'Open radial menu',
Expand All @@ -235,7 +247,7 @@ lib.addKeybind({
menuPage = 1
return lib.hideRadial()
end

menuPage = nil

if #menuItems == 0 or IsNuiFocused() or IsPauseMenuActive() then return end
Expand Down
7 changes: 5 additions & 2 deletions web/src/features/menu/radial/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,11 @@ const RadialMenu: React.FC = () => {

const changePage = async (increment?: boolean) => {
setVisible(false);
// May cause issues if user toggles off the menu while in transition?
await new Promise((resolve) => setTimeout(resolve, 100));

const didTransition: boolean = await fetchNui('radialTransition');

if (!didTransition) return;

setVisible(true);
setMenu({ ...menu, page: increment ? menu.page + 1 : menu.page - 1 });
};
Expand Down

0 comments on commit 6e1a978

Please sign in to comment.