Skip to content

fix(client): close active NUI elements before opening new ones#93

Open
YgorLeal wants to merge 1 commit intoCommunityOx:mainfrom
YgorLeal:fix/nui-focus-conflict
Open

fix(client): close active NUI elements before opening new ones#93
YgorLeal wants to merge 1 commit intoCommunityOx:mainfrom
YgorLeal:fix/nui-focus-conflict

Conversation

@YgorLeal
Copy link
Copy Markdown

@YgorLeal YgorLeal commented Mar 30, 2026

Summary

  • Fixes NUI focus bugs when multiple ox_lib UI elements overlap (e.g., opening an inputDialog while a context menu is open)
  • Root cause: keepInput in main.lua is a single variable that gets overwritten when a second UI opens, losing the original pre-NUI state
  • Adds lib.closeAllNui(except) that cleanly closes all other open NUI elements before a new one opens

Changes

  • main.lua: Added lib.closeAllNui(except) — closes context, menu, input, alert, and radial (with guards to avoid unnecessary resetNuiFocus calls)
  • context.lua: lib.showContext() calls lib.closeAllNui('context') before opening
  • input.lua: lib.inputDialog() calls lib.closeAllNui('input') before opening
  • alert.lua: lib.alertDialog() calls lib.closeAllNui('alert') before opening
  • menu.lua: lib.showMenu() calls lib.closeAllNui('menu') before opening

The except parameter ensures a UI type doesn't close itself (e.g., navigating between context sub-menus still works normally).

Test plan

  • Open a context menu, then trigger an inputDialog via script — context should close, input should open cleanly
  • Navigate context sub-menus — should work normally (except='context')
  • Open an input dialog, then trigger an alert — input should close (resolves nil), alert should open
  • Open a menu, then trigger a context menu — menu should close, context should open
  • Close any UI normally (no other UI open) — should work exactly as before

Prevents NUI focus bugs when multiple ox_lib UI elements overlap.
The keepInput variable in main.lua is a single scalar that gets
overwritten when a second UI opens, causing broken focus state when
either UI closes.

Adds lib.closeAllNui(except) which cleanly closes all other open
NUI elements before a new one opens, ensuring keepInput always
captures the true pre-NUI state.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant