Skip to content

Say when a spotlight search found nothing instead of selecting a filter - #34641

Merged
t3chguy merged 4 commits into
element-hq:developfrom
hayaksi1:pr/spotlight-no-results
Aug 26, 2026
Merged

Say when a spotlight search found nothing instead of selecting a filter#34641
t3chguy merged 4 commits into
element-hq:developfrom
hayaksi1:pr/spotlight-no-results

Conversation

@hayaksi1

@hayaksi1 hayaksi1 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Spotlight had no empty state, so a query matching nothing left the filter shortcuts underneath as
the only options in the dialog. The first option is selected by default, which made that the public
spaces shortcut, and pressing enter — the natural thing to do after typing — switched the dialog
into that filter. Getting back out needs backspace on an empty query, which is not discoverable, so
a mistyped search silently changed what was being searched.

The dialog now shows a no-results entry above the shortcuts when a query returns nothing. It takes
the default selection, so enter does nothing instead of choosing a filter, and it says why the list
is empty. The shortcuts are unchanged and still one arrow key away.

Worth flagging for review: under the people and public room filters the entry can show for a frame
while a server search is still in flight. Enter does nothing during that frame rather than creating
a room, which seems the safer of the two, but a loading guard is easy to add if you would rather it
did not appear at all.

Tests: a case in SpotlightDialog-test.tsx typing a query which matches nothing and pressing enter,
asserting no filter chip appears; it fails without the change.

Fixes #23726

Checklist

@hayaksi1
hayaksi1 requested a review from a team as a code owner August 8, 2026 19:23
@hayaksi1
hayaksi1 requested review from dbkr and t3chguy August 8, 2026 19:23
@github-actions github-actions Bot added the Z-Community-PR Issue is solved by a community member's PR label Aug 8, 2026
@t3chguy
t3chguy requested a review from a team August 10, 2026 09:20
@americanrefugee

Copy link
Copy Markdown

Please provide screenshots

@hayaksi1

Copy link
Copy Markdown
Contributor Author

@americanrefugee

Visual Changes

View / State Screenshot
Before — shortcuts only 1-before-shortcuts-only
Before — Enter selects filter 2-before-enter-selects-filter
After — no results 3-after-no-results

@americanrefugee americanrefugee left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

@t3chguy

t3chguy commented Aug 11, 2026

Copy link
Copy Markdown
Member

@hayaksi1 you have a failing screenshot test

@hayaksi1

Copy link
Copy Markdown
Contributor Author

@hayaksi1 you have a failing screenshot test

Do you want ss test files?

@t3chguy

t3chguy commented Aug 12, 2026

Copy link
Copy Markdown
Member
image

I want your PR to pass CI so we can merge it :)

Spotlight had no empty state, so a query matching nothing left the filter
shortcuts as the only options in the dialog. The first option is selected by
default, so pressing enter after typing switched the dialog into the public
spaces filter. Leaving that filter needs backspace on an empty query, which is
not discoverable, so a mistyped search quietly changed what was being searched.

A no-results entry now sits above the shortcuts when a query returns nothing. It
takes the default selection, so enter does nothing rather than choosing a filter,
and it says why the list is empty. The shortcuts are still one arrow key away.

The room directory screenshot covers a search that matches nothing, so it now
shows the new row and its baseline is regenerated. The one-result baseline in the
same spec is deliberately untouched: a search that does find something never
renders the row, and leaving that image alone keeps the diff honest about which
state actually changed.

Tests: a query matching nothing followed by enter leaves no filter applied.
@hayaksi1
hayaksi1 force-pushed the pr/spotlight-no-results branch from 4a35ed5 to 7cc0627 Compare August 12, 2026 13:35
@hayaksi1

Copy link
Copy Markdown
Contributor Author

@t3chguy Done.

@t3chguy

t3chguy commented Aug 12, 2026

Copy link
Copy Markdown
Member

hayaksi1(hayyaksi) force-pushed the pr/spotlight-no-results branch from 4a35ed5 to 7cc0627

I asked you not to force push in another PR already. Please read the contributing guide again.

@hayaksi1

Copy link
Copy Markdown
Contributor Author

@t3chguy Sorry for the mistake, will try to follow the rule.

The no results entry is an Option like every other row, and Option always drew the ↵ hint
into its end adornment, so a tile that exists purely to be inert still advertised a
keyboard shortcut. Its onClick is null precisely so that enter stops dropping the user
into a filter, which left the hint promising something that could not happen.

Option now draws the hint only when it was given an onClick. The stylesheet already takes
this line for the other case where enter would not fire — it hides the prompt whenever
focus leaves the search box, "as in this state pressing enter would not actuate that
option" — so this extends a rule the component already had rather than inventing one, and
any later option that is only there to be read gets it right without thinking about it.

Tests: the no results entry is asserted to render without the prompt while the start chat
shortcut beside it keeps one; it fails without the change. The room directory linux
screenshot is regenerated, and the one result shot next to it came back byte-identical,
which is what shows the render matches CI rather than quietly baking in a local one.
Comment thread apps/web/src/components/views/dialogs/spotlight/Option.tsx
The "No results found" entry has to be a listbox option so that it, rather
than one of the "other searches" shortcuts below it, takes the default
selection the roving tabindex hands to the first item that mounts. That is
the whole point of the entry: it gives the initial selection somewhere
harmless to land instead of dropping the user into a filter they never
asked for.

Routing it through AccessibleButton to get there was wrong, though. That
gave a row nobody can activate the click and Enter/Space handlers of a
button, plus the pointer cursor that comes with mx_AccessibleButton, so it
advertised an interaction it does not have.

Options without an onClick now render as a bare li carrying role="option"
and aria-disabled, which is the standard way to express an entry that is
present and announced but not selectable. Screen readers following
aria-activedescendant land on it and hear that there is nothing to pick,
and the shortcuts stay one arrow key away.
@hayaksi1
hayaksi1 force-pushed the pr/spotlight-no-results branch from 3b3953c to 9683922 Compare August 26, 2026 13:02
@t3chguy

t3chguy commented Aug 26, 2026

Copy link
Copy Markdown
Member
image

@hayaksi1 I have asked you on multiple occasions to not force push, as per our contributing guide.

@hayaksi1

Copy link
Copy Markdown
Contributor Author

@t3chguy That last update only changed the latest commit (3b3953c9683922). The earlier commits on the branch are the same, so the review history is still there.

@t3chguy
t3chguy enabled auto-merge August 26, 2026 14:46
@t3chguy
t3chguy added this pull request to the merge queue Aug 26, 2026
Merged via the queue into element-hq:develop with commit de231a6 Aug 26, 2026
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-Defect Z-Community-PR Issue is solved by a community member's PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spotlight search gets unhelpfully stuck in 'public room' search mode if you typo a search

4 participants