Skip to content

fix(web): keep selected language filters visible#1377

Open
DivyamTalwar wants to merge 4 commits into
sourcebot-dev:mainfrom
DivyamTalwar:divyamtalwar/fix-131-selected-language-filter
Open

fix(web): keep selected language filters visible#1377
DivyamTalwar wants to merge 4 commits into
sourcebot-dev:mainfrom
DivyamTalwar:divyamtalwar/fix-131-selected-language-filter

Conversation

@DivyamTalwar

@DivyamTalwar DivyamTalwar commented Jun 28, 2026

Copy link
Copy Markdown

Fixes #131

Problem

Selected language filters disappear when the filter-panel search text does not match their display name. That makes the active search query and the visible filter list disagree.

Root cause

The filter panel ran Fuse over all entries and rendered only matching results, so selected entries were dropped whenever they did not match the current text.

Solution

  • Always merge selected entries into the filtered result set before applying the existing selected-first sort.
  • Keep matching behavior for unselected entries unchanged.
  • Render filter rows as native toggle buttons with aria-pressed, so the filter controls are keyboard-accessible and announce selected state.

Tests

  • Added a regression test proving a selected PowerShell filter remains visible and pinned while searching for C.
  • Added coverage that filter entries render as accessible toggle buttons.
  • node .yarn/releases/yarn-4.7.0.cjs workspace @sourcebot/web test 'src/app/(app)/search/components/filterPanel/filter.test.tsx'
  • node .yarn/releases/yarn-4.7.0.cjs workspace @sourcebot/web exec eslint 'src/app/(app)/search/components/filterPanel/filter.tsx' 'src/app/(app)/search/components/filterPanel/filter.test.tsx' 'src/app/(app)/search/components/filterPanel/entry.tsx'
  • git diff --check

Risk

Low. The change is limited to filter-panel result membership and row semantics. Selected disabled rows remain clearable so users can remove incompatible filters.

Summary by CodeRabbit

  • Bug Fixes

    • Selected language filters remain visible when narrowing the filter list, and are prioritized ahead of matching unselected options.
    • Improved filter handling to avoid unintended reordering/mutation while searching.
  • Tests

    • Added new coverage for filter behavior, including selection visibility, match rendering, and non-matching items being hidden.
  • Accessibility / UI

    • Updated filter entries to use proper button semantics with aria-pressed and improved disabled/interaction behavior.
  • Documentation

    • Updated the changelog under Unreleased with the fix.

Constraint: Existing filter panel sorting already pins selected entries; the fix keeps that behavior while changing only filtered membership.

Rejected: Replacing the filter UI or changing Fuse matching | unnecessary scope for issue sourcebot-dev#131.

Confidence: high

Scope-risk: narrow

Directive: Keep selected filter chips visible even when the current filter text does not match their display name.

Tested: node .yarn/releases/yarn-4.7.0.cjs workspace @sourcebot/web test 'src/app/(app)/search/components/filterPanel/filter.test.tsx'; node .yarn/releases/yarn-4.7.0.cjs workspace @sourcebot/web lint

Not-tested: Full web build.
@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: be69b1e6-b2c7-4211-b092-ec57b895be8b

📥 Commits

Reviewing files that changed from the base of the PR and between 00f7742 and 58384ab.

📒 Files selected for processing (2)
  • packages/web/src/app/(app)/search/components/filterPanel/entry.tsx
  • packages/web/src/app/(app)/search/components/filterPanel/filter.test.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/web/src/app/(app)/search/components/filterPanel/filter.test.tsx

Walkthrough

Filter now keeps selected entries visible while narrowing search results and renders them ahead of matching non-selected entries. Entry is now a semantic button with selection state. Tests cover the updated behavior, and the changelog notes the fix.

Selected filter visibility fix

Layer / File(s) Summary
Filter search logic and render fix
packages/web/src/app/(app)/search/components/filterPanel/filter.tsx
Fuse result handling now merges selected entries with search matches via a Map, and rendering sorts a shallow copy of the memoized list instead of mutating it.
Entry button semantics
packages/web/src/app/(app)/search/components/filterPanel/entry.tsx
The entry container becomes a button with aria-pressed and disabled state, and the label/tooltip markup is restructured around span wrappers.
Test coverage and changelog
packages/web/src/app/(app)/search/components/filterPanel/filter.test.tsx, CHANGELOG.md
New Vitest/RTL tests verify button state, click handling, and search ordering/visibility, and the changelog records the visibility fix.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: keeping selected language filters visible.
Linked Issues check ✅ Passed The code and regression test implement #131 by preserving selected filters during search and pinning them first.
Out of Scope Changes check ✅ Passed The changes stay within the filter panel behavior and supporting UI/test updates, with no unrelated feature work.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Constraint: Sourcebot requires every non-doc PR to add an Unreleased changelog entry that links to the PR.

Confidence: high

Scope-risk: narrow

Directive: Keep future changelog entries under the matching Unreleased section and include the real PR link.

Tested: Changelog format matched adjacent Unreleased entries.

Not-tested: No code tests run for changelog-only commit.
Merge upstream main after sourcebot-dev#1376 changed the same Unreleased changelog block, keeping both release-note entries.

Constraint: GitHub reported PR sourcebot-dev#1377 as dirty against current main.\nRejected: Rewriting the open PR branch | Avoids force-pushing an existing review branch.\nConfidence: high\nScope-risk: narrow\nDirective: This merge commit should only resolve the changelog ordering conflict.\nTested: git diff --check\nNot-tested: Targeted regression test rerun follows after the merge commit.
@DivyamTalwar DivyamTalwar marked this pull request as ready for review June 28, 2026 00:42
Replace the filter option click container with a native toggle button while preserving selected entries as clearable controls.

Constraint: Frontend review found the existing filter row was mouse-only.\nRejected: Adding ARIA to a div | Native button semantics provide keyboard activation and focus behavior with less custom code.\nConfidence: high\nScope-risk: narrow\nDirective: Keep selected disabled entries clearable so users can remove incompatible filters.\nTested: node .yarn/releases/yarn-4.7.0.cjs workspace @sourcebot/web test 'src/app/(app)/search/components/filterPanel/filter.test.tsx'\nTested: node .yarn/releases/yarn-4.7.0.cjs workspace @sourcebot/web exec eslint 'src/app/(app)/search/components/filterPanel/filter.tsx' 'src/app/(app)/search/components/filterPanel/filter.test.tsx' 'src/app/(app)/search/components/filterPanel/entry.tsx'\nTested: git diff --check\nNot-tested: Full web build not rerun for this narrow component accessibility change.
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.

Filtering languages hides already selected langs

1 participant