Skip to content

fix: unify chip-remove event — both modes emit ol-filter-change#40

Merged
mekarpeles merged 2 commits intomainfrom
fix/unify-filter-change-event
Apr 27, 2026
Merged

fix: unify chip-remove event — both modes emit ol-filter-change#40
mekarpeles merged 2 commits intomainfrom
fix/unify-filter-change-event

Conversation

@mekarpeles
Copy link
Copy Markdown
Member

Closes #34

What changed

ol-search-bar.js_handleChipRemove embedded branch now computes the new filter value from _localFilters (same logic as the droppable branch) and dispatches ol-filter-change with { filter, value } instead of ol-chip-remove with { type, value }.

ol-search-page.js_onChipRemove handler and its ol-chip-remove event listener removed. _onFilterChange already handled all seven filter fields correctly, so no logic was lost — just the duplicate handler.

ol-catalog.js + README.md — documentation updated to reflect the unified event.

Why

A host of ol-search-bar previously needed two listeners (ol-chip-remove and ol-filter-change) with two different payload shapes to handle the same user action (clicking × on a chip) depending on which mode the component was in. Now any host listens for exactly one event.

Verified by

4 new static-analysis tests in ol-search-bar.events.test.js:

  • ol-search-bar source contains no ol-chip-remove
  • ol-search-page source contains no ol-chip-remove
  • _handleChipRemove dispatches ol-filter-change
  • _onFilterChange covers all seven filter fields

171 tests pass, lint clean.

closes #34

Previously _handleChipRemove dispatched ol-chip-remove in embedded mode
and ol-filter-change (via _emitFilter) in droppable mode. ol-search-page
maintained a separate _onChipRemove handler wired to ol-chip-remove in
addition to _onFilterChange.

Now the embedded branch computes the new filter value from _localFilters
(same logic as the droppable branch) and dispatches ol-filter-change with
{ filter, value }. ol-search-page's _onFilterChange already handles every
filter field so _onChipRemove and its event listener are removed.

Four static-analysis tests in ol-search-bar.events.test.js verify the
contract: no ol-chip-remove in either source file, _handleChipRemove
dispatches ol-filter-change, _onFilterChange covers all seven fields.
Copilot AI review requested due to automatic review settings April 26, 2026 22:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Unifies chip removal behavior so ol-search-bar emits a single ol-filter-change event (with { filter, value }) in both droppable and embedded modes, removing the legacy ol-chip-remove event path.

Changes:

  • Updated ol-search-bar embedded-mode chip removal to dispatch ol-filter-change instead of ol-chip-remove.
  • Removed ol-chip-remove listener and handler from ol-search-page to eliminate duplicated state-update logic.
  • Added static-analysis tests and updated docs to reflect the unified event API.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
frontend/src/components/ol-search-page.js Removes ol-chip-remove wiring/handler; relies solely on ol-filter-change.
frontend/src/components/ol-search-bar.js Updates embedded chip × behavior to dispatch ol-filter-change with { filter, value }.
frontend/src/components/ol-search-bar.events.test.js Adds static-analysis tests asserting removal of ol-chip-remove and coverage of filter fields.
frontend/src/components/ol-catalog.js Updates component catalog documentation to reference ol-filter-change.
frontend/src/components/README.md Updates docs to remove ol-chip-remove and describe unified ol-filter-change.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread frontend/src/components/ol-search-bar.js Outdated
Comment thread frontend/src/components/ol-search-bar.js
Comment thread frontend/src/components/ol-catalog.js Outdated
Comment thread frontend/src/components/README.md
- _handleChipRemove embedded path now uses this.filters (prop) as source
  of truth for multi-value array lookups; falls back to _localFilters
  only if filters prop was not provided — prevents clearing an entire
  genre/author/subject array when the host passes filters correctly
- JSDoc updated: embedded mode now documents that both .chips and
  .filters are required for correct multi-value chip removal
- catalog.js embedded example now passes .filters alongside .chips
- README updated to note that .filters is required in embedded mode
@mekarpeles mekarpeles merged commit 3c205f2 into main Apr 27, 2026
2 checks passed
@mekarpeles mekarpeles deleted the fix/unify-filter-change-event branch April 27, 2026 00:07
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.

fix: unify chip-remove event — emit ol-filter-change in both modes

2 participants