mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-28 22:01:29 +00:00
fix(esx_menu_dialog, esx_menu_list): do not grab NUI focus after the menu closed
Opening a menu schedules SetNuiFocus(true, true) 200 ms later so the NUI has time to render. Closing sets the focus off but does not cancel that timer, so a menu closed within those 200 ms leaves the timer to fire afterwards and turn the focus back on with nothing open: the player gets a cursor and loses movement and input until another menu is opened and closed. esx_menu_list never stored the timer id at all, so it could not be cancelled in any case. Checking inside the callback whether a menu is still open fixes both, and also covers a quick open-close-open where cancelling by id would drop a focus that is still wanted. esx_menu_default is unaffected, it has no timer. Tested on artifact 25770 with a dialog closed 50 ms after opening: before, IsNuiFocused() was still true 600 ms later; after, it stays false.
This commit is contained in:
@@ -15,7 +15,9 @@ local function openMenu(namespace, name, data)
|
||||
})
|
||||
|
||||
local timeoutId = ESX.SetTimeout(200, function()
|
||||
SetNuiFocus(true, true)
|
||||
if next(OpenedMenus) then
|
||||
SetNuiFocus(true, true)
|
||||
end
|
||||
end)
|
||||
|
||||
table.insert(Timeouts, timeoutId)
|
||||
|
||||
@@ -12,7 +12,9 @@ CreateThread(function()
|
||||
data = data,
|
||||
})
|
||||
SetTimeout(200, function()
|
||||
SetNuiFocus(true, true)
|
||||
if next(OpenedMenus) then
|
||||
SetNuiFocus(true, true)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user