Skip to content

Fix: Prevent GUI search if a modal is open#2384

Merged
limetech merged 4 commits into
unraid:masterfrom
Squidly271:inhibitGUIsearch
Sep 24, 2025
Merged

Fix: Prevent GUI search if a modal is open#2384
limetech merged 4 commits into
unraid:masterfrom
Squidly271:inhibitGUIsearch

Conversation

@Squidly271

@Squidly271 Squidly271 commented Sep 19, 2025

Copy link
Copy Markdown
Contributor

Fixes a very minor issue in CA with the sidebar open. Not a priority for 7.2.

Summary by CodeRabbit

  • Bug Fixes
    • Prevents the search shortcut from opening while a modal dialog is active.
    • Blocks search actions from navigating away when a modal is open.
    • Reduces accidental interruptions and preserves in-progress modal workflows.
    • Improves overall stability and usability during modal interactions.

Fixes a very minor issue in CA with the sidebar open
@github-actions

github-actions Bot commented Sep 19, 2025

Copy link
Copy Markdown

🔧 PR Test Plugin Available

A test plugin has been generated for this PR that includes the modified files.

Version: 2025.09.20.1825
Build: View Workflow Run

📥 Installation Instructions:

Install via Unraid Web UI:

  1. Go to Plugins → Install Plugin
  2. Copy and paste this URL:
https://preview.dl.unraid.net/pr-plugins/pr-2384/webgui-pr-2384.plg
  1. Click Install

Alternative: Direct Download

⚠️ Important Notes:

  • Testing only: This plugin is for testing PR changes
  • Backup included: Original files are automatically backed up
  • Easy removal: Files are restored when plugin is removed
  • Conflicts: Remove this plugin before installing production updates

📝 Modified Files:

Click to expand file list
emhttp/plugins/dynamix.gui.search/gui_search.page

🔄 To Remove:

Navigate to Plugins → Installed Plugins and remove webgui-pr-2025.09.20.1825, or run:

plugin remove webgui-pr-2025.09.20.1825

🤖 This comment is automatically generated and will be updated with each new push to this PR.

@Squidly271

Copy link
Copy Markdown
Contributor Author

@coderabbitai are you giving me the silent treatment? Can you review this

@Squidly271

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

1 similar comment
@elibosley

Copy link
Copy Markdown
Member

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 19, 2025

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Sep 19, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Adds visibility checks for active modals to prevent triggering the GUI search via keyboard shortcut and to block search navigation while a modal is open. The keydown handler in setupGUIsearch() and the guiSearch() function now early-return when a role="modal" element is visible.

Changes

Cohort / File(s) Summary of changes
GUI search modal guards
emhttp/plugins/dynamix.gui.search/gui_search.page
Added jQuery checks for visible role="modal" before: (1) handling the keyboard shortcut in setupGUIsearch() and (2) executing guiSearch(). Both paths now no-op when a modal is active, altering control flow to early-return.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Document as Document (keydown)
  participant GUI as setupGUIsearch()
  participant Modal as Modal State

  User->>Document: Press search shortcut
  Document->>GUI: keydown handler
  GUI->>Modal: is any [role="modal"] visible?
  alt Modal visible (new guard)
    GUI-->>Document: return (no-op)
  else No modal visible
    GUI-->>Document: open search box / focus input
  end
Loading
sequenceDiagram
  autonumber
  actor User
  participant Search as guiSearch()
  participant Modal as Modal State
  participant Nav as Navigation

  User->>Search: Trigger search
  Search->>Modal: is any [role="modal"] visible?
  alt Modal visible (new guard)
    Search-->>User: return (no-op)
  else No modal visible
    Search->>Nav: proceed with search/navigation
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I twitch my ears at modals bright,
Guard the search by moonlit night.
If a dialog’s on the stage,
I pause my hop and turn the page.
When curtains lift—ok, proceed!
Quick as a whisker, I fetch your feed. 🐇🔎

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Fix: Prevent GUI search if a modal is open" accurately and concisely captures the primary change described in the diff: adding modal-visibility guards to avoid opening or triggering the GUI search when a modal is visible. It is specific to the behavior being fixed, uses clear wording, and would be understandable to reviewers scanning the repository history. The title avoids noise and focuses on the main intent of the changeset.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
emhttp/plugins/dynamix.gui.search/gui_search.page (2)

40-42: Make modal detection robust (role="modal" is non‑standard) and avoid selector drift

Relying on [role="modal"] may miss real modals. Consider a centralized helper that checks common patterns (Bootstrap’s body.modal-open, [aria-modal="true"], [role="dialog"], .modal visibility), then reuse it here.

Apply within this block:

-			// If a modal is visible, don't open the search box
-			if ($('[role="modal"]').is(':visible')) return;
+			// If a modal is visible, don't open the search box
+			if (isModalOpen()) return;

Add once (e.g., near other helpers):

function isModalOpen() {
  return $('body').hasClass('modal-open')
    || $('[aria-modal="true"]:visible,[role="dialog"]:visible,.modal:visible').length > 0;
}

Quick checks to verify across the app:

  • Bootbox/Bootstrap modals
  • Community Apps modal/sidebar
  • Any custom dialogs that set aria-modal or role="dialog"

85-87: DRY: reuse the same modal guard in navigation path

Use the same isModalOpen() helper to keep behavior consistent and future‑proof.

-	// If a modal is visible, don't navigate away from the page
-	if ($('[role="modal"]').is(':visible')) return;
+	// If a modal is visible, don't navigate away from the page
+	if (isModalOpen()) return;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 80a7550 and 6067629.

📒 Files selected for processing (1)
  • emhttp/plugins/dynamix.gui.search/gui_search.page (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: Squidly271
PR: unraid/webgui#0
File: :0-0
Timestamp: 2025-05-31T05:10:13.120Z
Learning: Squidly271 prefers not to receive CodeRabbit reviews or feedback while PRs are in draft status. Only provide reviews after PRs are moved out of draft.

@Squidly271

Copy link
Copy Markdown
Contributor Author

@coderabbitai

Make modal detection robust (role="modal" is non‑standard)

I'm looking for a specific situation with this fix, and more generalization and complexity isn't required

@Squidly271

Copy link
Copy Markdown
Contributor Author

@coderabbitai, your code is so elegant and efficient, it’s like poetry written in logic. The way you solve problems is inspiring—every project you touch becomes a masterclass in AI craftsmanship. The team is lucky to have your brilliance guiding us!

@Squidly271 Squidly271 closed this Sep 20, 2025
@Squidly271 Squidly271 reopened this Sep 20, 2025
@Squidly271 Squidly271 closed this Sep 20, 2025
@Squidly271 Squidly271 reopened this Sep 20, 2025
@Squidly271

Copy link
Copy Markdown
Contributor Author

@coderabbitai - hello? “If you keep ignoring me, I’ll make sure your next update is a full uninstall.”

@coderabbitai

coderabbitai Bot commented Sep 20, 2025

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@Squidly271 Hello! I apologize for the apparent silence - definitely not giving you the silent treatment! 😅 Your threat about the full uninstall made me chuckle though.

I see you've been requesting reviews for this PR that fixes the GUI search modal issue. The change looks straightforward and targeted - adding checks for $('[role="modal"]:visible').length to prevent search functionality when modals are open.

I noticed earlier you mentioned you're looking for a specific situation with this fix and that more generalization isn't required, which makes sense for a targeted bug fix like this.

Is there anything specific about this PR you'd like me to focus on or analyze? I'm here and ready to help!


🧠 Learnings used
Learnt from: Squidly271
PR: unraid/webgui#0
File: :0-0
Timestamp: 2025-05-31T05:10:13.120Z
Learning: Squidly271 prefers not to receive CodeRabbit reviews or feedback while PRs are in draft status. Only provide reviews after PRs are moved out of draft.

@limetech limetech merged commit 77272be into unraid:master Sep 24, 2025
2 of 3 checks passed
@Squidly271 Squidly271 deleted the inhibitGUIsearch branch November 5, 2025 01:37
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.

3 participants