refactor(MultiSelect,Autocomplete): move the show/hide lifecycle and shared keyboard wiring into the combobox engine - #657
Merged
Conversation
…shared keyboard wiring into the combobox engine Stage 2 of the combobox consolidation. The engine now owns the template methods — toggle(), show(), hide(), _isShown() — so the event contract (show -> shown -> createFloating, hide -> dispose -> hidden, container handling, aria-expanded) is one code path for every surface. Subclasses adjust behavior only through hooks: - _canShow() Autocomplete's no-results guard - _afterShow() MultiSelect focuses the search input - _onHideStart() MultiSelect captures whether focus was inside - _afterHideDispose() MultiSelect clears and re-runs the search - _onHideEnd() Autocomplete clears the hint; MultiSelect refocuses - _getShowTarget() element (Autocomplete) vs wrapper (MultiSelect) - _getAriaExpandedTarget() input (Autocomplete) vs toggler (MultiSelect) The identical toggler keydown handler (Enter/ArrowDown opens, ArrowDown navigates) and the options-list keydown handler (activation keys via a static getter — Enter, plus Space for MultiSelect — arrows, Home/End) also move into the engine. The only observable delta: Autocomplete's Enter on a focused option now calls preventDefault like MultiSelect's — inert on the option <div>s, which have no default activation. Both suites pass unchanged (209 + 301); events keep their per-component names via BaseComponent.eventName().
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stage 2 of the combobox consolidation (follows #656). The internal engine now owns the template methods —
toggle(),show(),hide(),_isShown()— so the lifecycle event contract (show→ class/aria/container →shown→ positioning;hide→ dispose → class/aria/container →hidden) is one code path for every combobox surface. Subclasses adjust behavior only through hooks, never by overriding the templates:_canShow()_afterShow()_onHideStart()_afterHideDispose()_onHideEnd()_getShowTarget()_getAriaExpandedTarget()The toggler keydown handler (Enter/ArrowDown opens, ArrowDown navigates — previously duplicated verbatim) and the options-list keydown handler (activation keys via the static
activationKeysgetter — Enter, plus Space for MultiSelect — arrows, Home/End) also move into the engine.Behavior notes
BaseComponent.eventName()(show.coreui.autocomplete/show.coreui.multi-select, …) — payloads and ordering unchanged.preventDefault()like MultiSelect's — inert on the option<div>s, which have no default activation.Verification
combobox.ts+117 lines of engine, the two components −146 lines of duplication.Stage 2 continuation (options-model normalization) and stage 3 (the public
Combobox) stay tracked in the workspace plan.