Skip to content

Desktop: Fix#15147 editor disappearing when search is triggered with empty query#15148

Open
MANVENDRA-github wants to merge 2 commits intolaurent22:devfrom
MANVENDRA-github:fix/15147-searchbar-empty-query-crash
Open

Desktop: Fix#15147 editor disappearing when search is triggered with empty query#15148
MANVENDRA-github wants to merge 2 commits intolaurent22:devfrom
MANVENDRA-github:fix/15147-searchbar-empty-query-crash

Conversation

@MANVENDRA-github
Copy link
Copy Markdown
Contributor

@MANVENDRA-github MANVENDRA-github commented Apr 19, 2026

Fixes #15147

Summary:
Fixes an issue where clicking the search button when the search input is small can cause the editor and notes pane to disappear.

Root cause:
Search mode was being activated even when the query was empty. This led to entering a search state with no results, which in certain layouts (e.g., when the sidebar is very narrow) caused the UI to collapse and the editor to disappear.

Fix:
Added a guard in SearchBar.onSearchButtonClick to prevent entering search mode when the query is empty or whitespace-only. In such cases, the input is focused without dispatching FOCUS_SET

Before the fix:

Recording.2026-04-19.192512.mp4

After the fix:

Recording.2026-04-19.191537.mp4

@coderabbitai coderabbitai Bot added bug It's a bug desktop All desktop platforms search labels Apr 19, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/app-desktop/gui/SearchBar/SearchBar.tsx (1)

135-138: Minor: condition can be simplified.

!query || query.trim().length === 0 is redundant — an empty string's trim().length is already 0, so !query.trim() covers both cases.

♻️ Proposed simplification
-			if (!query || query.trim().length === 0) {
+			if (!query.trim()) {
 				focus('SearchBar::onSearchButtonClick', props.inputRef.current);
 				return;
 			}

Also worth confirming: if props.inputRef.current can ever be null at this point, focus() should handle it gracefully — please double-check the focus helper tolerates a null target.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/app-desktop/gui/SearchBar/SearchBar.tsx` around lines 135 - 138,
Simplify the empty-query check inside SearchBar::onSearchButtonClick by
replacing the redundant condition `!query || query.trim().length === 0` with
`!query.trim()` and ensure you reference the same symbols
(`onSearchButtonClick`, `props.inputRef.current`, and the `focus` helper);
additionally, confirm that `focus` tolerates a null target—if it doesn't, add a
null guard around the `focus('SearchBar::onSearchButtonClick',
props.inputRef.current)` call to avoid calling it with a null ref.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/app-desktop/gui/SearchBar/SearchBar.tsx`:
- Around line 135-138: Simplify the empty-query check inside
SearchBar::onSearchButtonClick by replacing the redundant condition `!query ||
query.trim().length === 0` with `!query.trim()` and ensure you reference the
same symbols (`onSearchButtonClick`, `props.inputRef.current`, and the `focus`
helper); additionally, confirm that `focus` tolerates a null target—if it
doesn't, add a null guard around the `focus('SearchBar::onSearchButtonClick',
props.inputRef.current)` call to avoid calling it with a null ref.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e0ade1ec-0f11-4b2a-877d-d763987d4d4e

📥 Commits

Reviewing files that changed from the base of the PR and between b49047e and 68806ef.

📒 Files selected for processing (1)
  • packages/app-desktop/gui/SearchBar/SearchBar.tsx

@github-actions github-actions Bot deleted a comment from coderabbitai Bot Apr 19, 2026
@github-actions github-actions Bot deleted a comment from coderabbitai Bot Apr 19, 2026
@MANVENDRA-github MANVENDRA-github changed the title Fix#15147 editor disappearing when search is triggered with empty query Desktop: Fix#15147 editor disappearing when search is triggered with empty query Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug It's a bug desktop All desktop platforms search

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Desktop: Notes and editor disappear when search bar is small and clicked

1 participant