Skip to content

fix(ui5-shellbar-search): keep ShellBar state in sync on empty Enter#13834

Open
dobrinyonkov wants to merge 1 commit into
UI5:mainfrom
dobrinyonkov:fix/shellbar-search-enter-sync
Open

fix(ui5-shellbar-search): keep ShellBar state in sync on empty Enter#13834
dobrinyonkov wants to merge 1 commit into
UI5:mainfrom
dobrinyonkov:fix/shellbar-search-enter-sync

Conversation

@dobrinyonkov

@dobrinyonkov dobrinyonkov commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

SNOW: DINC0942674

Problem

Focus the shellbar search (empty, expanded) and press Enter. The search field collapses to an icon, but the ShellBar keeps its expanded layout. The two get out of sync.

Cause

ShellBarSearch._handleEnter() (added in #13523) collapses the field on empty Enter by setting this.collapsed = true directly. It skips super._handleEnter(), so the ui5-search event never fires.

The ShellBar tracks the search state separately through its adaptor, which only reacts to ui5-open, ui5-close, and ui5-search. With no event, the adaptor never learns the field collapsed, so showSearchField stays true.

Fix

Fire ui5-search before collapsing. The adaptor then flips showSearchField to false, so both stay in sync. Standalone usage still self-collapses and restores focus to the button.

Tests

Added a test in ShellBar.cy.tsx: mount the search inside a ShellBar, press Enter on empty, and check both collapsed === true and showSearchField === false. The existing standalone test from #13523 still passes.

Pressing Enter in an empty, expanded shellbar search collapsed the
search field internally via `this.collapsed = true`, but skipped
`super._handleEnter()` and therefore never fired the `ui5-search`
event. The ShellBar tracks the search's expanded/collapsed state
separately through its search adaptor, which only reacts to
`ui5-open`/`ui5-close`/`ui5-search`. As a result the field collapsed
visually while the ShellBar remained in its expanded layout.

The empty-Enter branch now fires `ui5-search` before collapsing
locally. When embedded in a ShellBar, the adaptor toggles
`showSearchField` and the next render syncs `collapsed`, so both stay
aligned. Standalone usage still self-collapses and restores focus to
the button as before.
@dobrinyonkov
dobrinyonkov force-pushed the fix/shellbar-search-enter-sync branch from a94a003 to f6a5f47 Compare July 16, 2026 11:08
@dobrinyonkov
dobrinyonkov requested a review from niyap July 16, 2026 11:11
@dobrinyonkov dobrinyonkov assigned MapTo0 and unassigned MapTo0 Jul 16, 2026
@dobrinyonkov
dobrinyonkov requested a review from MapTo0 July 16, 2026 11:11
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.

2 participants