fix: detect mutated filters prop; add CSS breakpoint drift tests#38
Merged
mekarpeles merged 2 commits intomainfrom Apr 27, 2026
Merged
fix: detect mutated filters prop; add CSS breakpoint drift tests#38mekarpeles merged 2 commits intomainfrom
mekarpeles merged 2 commits intomainfrom
Conversation
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.
Contributor
There was a problem hiding this comment.
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
hasChangedoverride for thefiltersLit property usingJSON.stringifycomparison. - Adds Vitest static-analysis assertions ensuring
ol-search-bar.jscontains@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.
- 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
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.
Closes #32, closes #31
hasChanged on
filterspropLit'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 noupdated()call —_localFiltersin embedded mode silently stays stale and the chip bar shows the wrong state.JSON.stringifycomparison catches both reference changes and in-place mutations at negligible cost for a 7-key object.CSS @media breakpoint drift detection
BREAKPOINTS.jsis the canonical source formobile: 600,narrow: 785,wide: 900but CSS@mediaqueries can't import JS — they duplicate the values as literals. Two new static-analysis assertions inbreakpoints.test.jsverify thatol-search-bar.jscontains@mediablocks at exactly600pxand785px. 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); }onfiltersproperty@media (max-width: 600px)drift test passes@media (max-width: 785px)drift test passes