fix(client/interface): reset nui focus on alert (#192)

This commit is contained in:
Hepic Greg
2022-12-30 11:16:33 +01:00
committed by GitHub
parent a2772a87b4
commit 86d66b85c1

View File

@@ -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)