mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 15:36:02 +01:00
fix(client/interface): reset nui focus on alert (#192)
This commit is contained in:
@@ -1,4 +1,10 @@
|
|||||||
local alert = nil
|
local alert = nil
|
||||||
|
local keepInput = IsNuiFocusKeepingInput()
|
||||||
|
|
||||||
|
local function resetFocus()
|
||||||
|
SetNuiFocus(false, false)
|
||||||
|
SetNuiFocusKeepInput(keepInput)
|
||||||
|
end
|
||||||
|
|
||||||
---@class AlertDialogProps
|
---@class AlertDialogProps
|
||||||
---@field header string;
|
---@field header string;
|
||||||
@@ -13,7 +19,10 @@ function lib.alertDialog(data)
|
|||||||
if alert then return end
|
if alert then return end
|
||||||
alert = promise.new()
|
alert = promise.new()
|
||||||
|
|
||||||
|
keepInput = IsNuiFocusKeepingInput()
|
||||||
|
|
||||||
SetNuiFocus(true, true)
|
SetNuiFocus(true, true)
|
||||||
|
SetNuiFocusKeepInput(false)
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
action = 'sendAlert',
|
action = 'sendAlert',
|
||||||
data = data
|
data = data
|
||||||
@@ -26,7 +35,7 @@ function lib.closeAlertDialog()
|
|||||||
if not alert then return end
|
if not alert then return end
|
||||||
alert:resolve(nil)
|
alert:resolve(nil)
|
||||||
alert = nil
|
alert = nil
|
||||||
SetNuiFocus(false, false)
|
resetFocus()
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
action = 'closeAlertDialog'
|
action = 'closeAlertDialog'
|
||||||
})
|
})
|
||||||
@@ -35,7 +44,7 @@ end
|
|||||||
|
|
||||||
RegisterNUICallback('closeAlert', function(data, cb)
|
RegisterNUICallback('closeAlert', function(data, cb)
|
||||||
cb(1)
|
cb(1)
|
||||||
SetNuiFocus(false, false)
|
resetFocus()
|
||||||
local promise = alert
|
local promise = alert
|
||||||
alert = nil
|
alert = nil
|
||||||
promise:resolve(data)
|
promise:resolve(data)
|
||||||
|
|||||||
Reference in New Issue
Block a user