Skip to content

fix: detect mutated filters prop; add CSS breakpoint drift tests#38

Merged
mekarpeles merged 2 commits intomainfrom
fix/filter-haschanged-breakpoint-tests
Apr 27, 2026
Merged

fix: detect mutated filters prop; add CSS breakpoint drift tests#38
mekarpeles merged 2 commits intomainfrom
fix/filter-haschanged-breakpoint-tests

Conversation

@mekarpeles
Copy link
Copy Markdown
Member

Closes #32, closes #31

hasChanged on filters prop

Lit's default property comparison uses ===. A parent that mutates the filters object in place (this.searchBar.filters.sort = 'new' instead of replacing the reference) gets no updated() call — _localFilters in embedded mode silently stays stale and the chip bar shows the wrong state.

JSON.stringify comparison catches both reference changes and in-place mutations at negligible cost for a 7-key object.

CSS @media breakpoint drift detection

BREAKPOINTS.js is the canonical source for mobile: 600, narrow: 785, wide: 900 but CSS @media queries can't import JS — they duplicate the values as literals. Two new static-analysis assertions in breakpoints.test.js verify that ol-search-bar.js contains @media blocks at exactly 600px and 785px. The test suite now fails immediately if either value is changed without updating the other side.

Done checklist

  • hasChanged(n, o) { return JSON.stringify(n) !== JSON.stringify(o); } on filters property
  • @media (max-width: 600px) drift test passes
  • @media (max-width: 785px) drift test passes
  • 169 tests pass, lint clean

closes #32, closes #31

hasChanged on the filters property (ol-search-bar):
  Default Lit property comparison uses ===. A parent that mutates the
  filters object in place (filters.sort = 'new' instead of replacing the
  reference) produces no updated() call, so _localFilters silently stays
  stale. JSON.stringify comparison catches both reference changes and
  in-place mutations.

CSS @media drift detection (breakpoints.test.js):
  BREAKPOINTS.js is the canonical definition but CSS @media queries must
  duplicate the values as literals. Two new static-analysis assertions
  verify that ol-search-bar.js CSS contains @media blocks at exactly
  600px (BREAKPOINTS.mobile) and 785px (BREAKPOINTS.narrow). The test
  suite now fails if either value drifts without updating the CSS.
Copilot AI review requested due to automatic review settings April 26, 2026 22:45
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

This PR aims to (1) keep ol-search-bar’s embedded-mode _localFilters in sync even when callers mutate the filters object in place, and (2) add static-analysis tests that catch drift between JS BREAKPOINTS constants and hardcoded CSS @media breakpoints in ol-search-bar.js.

Changes:

  • Adds a hasChanged override for the filters Lit property using JSON.stringify comparison.
  • Adds Vitest static-analysis assertions ensuring ol-search-bar.js contains @media (max-width: 600px) and @media (max-width: 785px) blocks.

Reviewed changes

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

File Description
frontend/src/components/ol-search-bar.js Adds hasChanged override on the filters property to try to detect mutated filter state.
frontend/src/utils/breakpoints.test.js Adds CSS breakpoint drift assertions for @media (max-width: 600px) and @media (max-width: 785px) in ol-search-bar.js.

💡 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/utils/breakpoints.test.js Outdated
- Remove hasChanged from filters property — JSON.stringify comparison
  cannot detect in-place mutations (Lit never calls the setter), and all
  callers already replace the object immutably; add a comment documenting
  the immutable-update requirement instead
- Breakpoint CSS drift tests now build regexes from BREAKPOINTS.mobile /
  BREAKPOINTS.narrow constants instead of hardcoding 600/785 twice
@mekarpeles mekarpeles merged commit acd1a21 into main Apr 27, 2026
2 checks passed
@mekarpeles mekarpeles deleted the fix/filter-haschanged-breakpoint-tests branch April 27, 2026 00:06
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: filters prop mutation in embedded ol-search-bar goes undetected fix: CSS @media breakpoints must manually mirror JS BREAKPOINTS constants

2 participants