fix(ui): ImGui ID collisions and missing popup-open trigger

- Util/SearchSelector.cs ImRaii.PushId(id) collapsed every row in the
  filtered list to the same ImGui ID, leaving the ID stack ambiguous
  for click resolution. Mix the row index into the pushed id so every
  Selectable has a distinct ImGui identifier
- Ui/SettingsTabs/Chat.cs blocked-emote add-button never opened the
  selector popup because SearchSelector.SelectorPopup is wrapped in
  ImRaii.ContextPopupItem (right-click semantics). Detect the
  IsItemClicked() event after the button and call ImGui.OpenPopup
  explicitly so left-click opens the picker too
This commit is contained in:
2026-05-03 22:05:57 +02:00
parent a10c115b9b
commit af7c757e63
2 changed files with 12 additions and 1 deletions
+7
View File
@@ -169,6 +169,13 @@ internal sealed class Chat : ISettingsTab
using (Plugin.FontManager.FontAwesome.Push()) using (Plugin.FontManager.FontAwesome.Push())
ImGui.Button(FontAwesomeIcon.Plus.ToIconString(), new Vector2(buttonWidth, 0)); ImGui.Button(FontAwesomeIcon.Plus.ToIconString(), new Vector2(buttonWidth, 0));
// Open the selector popup on left-click; SelectorPopup uses
// ImRaii.ContextPopupItem internally which only opens on right-
// click otherwise — without this OpenPopup the button looked
// active but the popup never appeared on a normal click.
if (ImGui.IsItemClicked())
ImGui.OpenPopup("WordAddPopup");
if (SearchSelector.SelectorPopup("WordAddPopup", out var newWord, WordPopupOptions)) if (SearchSelector.SelectorPopup("WordAddPopup", out var newWord, WordPopupOptions))
{ {
Mutable.BlockedEmotes.Add(newWord); Mutable.BlockedEmotes.Add(newWord);
+5 -1
View File
@@ -84,7 +84,11 @@ public static class SearchSelector
foreach (var i in clipper.Rows) foreach (var i in clipper.Rows)
{ {
var searched = FilteredSearchSheet[i]; var searched = FilteredSearchSheet[i];
using var pushedId = ImRaii.PushId(id); // Mix the row index into the ImGui ID so each Selectable in
// the loop has a distinct ID — using the same id for every
// row collapsed all rows to a single ID-stack entry and made
// selection ambiguous.
using var pushedId = ImRaii.PushId($"{id}##{i}");
if (!drawSelectable(searched, options.IsSelected(searched))) if (!drawSelectable(searched, options.IsSelected(searched)))
continue; continue;