Skip to content

fix/multifilter#891

Open
revolist wants to merge 5 commits into
mainfrom
feat/close-multigrid-filter
Open

fix/multifilter#891
revolist wants to merge 5 commits into
mainfrom
feat/close-multigrid-filter

Conversation

@revolist

@revolist revolist commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Bug Fixes

    • Filter panels now correctly limit to a single open panel across multiple grids.
    • Improved outside-click and ownership detection so panels attach to the correct grid, including Shadow DOM scenarios.
    • Relaxed dialog/panel positioning checks to reduce spurious alignment failures.
  • Tests

    • Added end-to-end test validating multi-grid filter panel behavior and automatic panel switching.

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 920b2a20-209e-4f85-9850-f2d552c7aaab

📥 Commits

Reviewing files that changed from the base of the PR and between dd3df8f and 538b9c1.

📒 Files selected for processing (1)
  • e2e/filtering.spec.ts

Walkthrough

FilterPanel now scopes add-filter queries to the component and adds ShadowRoot-aware ownership checks so clicking a filter button in one revo-grid closes another grid’s panel; isFilterBtn typing was generalized; an e2e test mounts two grids to verify single-panel behavior and dialog-position tolerances were relaxed.

Changes

Multi-Grid Filter Panel Isolation

Layer / File(s) Summary
Stencil Element import & decorator updates
src/plugins/filter/filter.panel.tsx
Alias Stencil Element import and switch the component element decorator to @StencilElement().
Shadow DOM helpers and outside-click handling
src/plugins/filter/filter.panel.tsx
Add getAddFilterSelect(), isOwnFilterButton(), and getOwningGrid(); update onMouseDown to ignore clicks from this panel's own controls using ShadowRoot/revo-grid ownership checks.
Component-scoped add-filter select usage and focus/reset flows
src/plugins/filter/filter.panel.tsx
Replace global document.getElementById('add-filter') with getAddFilterSelect() in onAddNewFilter and renderExtra (focus-next and Enter-key paths) to reset and refocus the per-panel select.
isFilterBtn parameter generalization
src/plugins/filter/filter.button.tsx
Change isFilterBtn parameter type from HTMLElement to Element without behavioral change.
E2E multi-grid test and dialog tolerance tweak
e2e/filtering.spec.ts
Add Playwright test that renders two revo-grid instances, opens each grid's filter panel to verify only one panel is open and it switches ownership; relax dialog/button alignment delta in an existing layout assertion.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • revolist/revogrid#890: Both PRs modify the filter panel implementation and related E2E coverage for dialog-style positioning/open-state behavior.
  • revolist/revogrid#719: Overlaps on FilterPanel input-handling and renderExtra/Enter-key refactors.
  • revolist/revogrid#847: Related filter panel toggle/close behavior and e2e coverage.

Suggested labels

bug, javascript

Suggested reviewers

  • m2a2x

Poem

🐰
I hopped through shadows, sniffed the code,
Two grids once tangled on the road.
One click, one panel—now they part,
Each filter tending its own chart.
Cheers from my whiskers, light and bold!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'fix/multifilter' is vague and uses a generic term that doesn't clearly convey the specific change; it reads like a branch name rather than a descriptive PR title. Use a descriptive title that clearly summarizes the main change, such as 'Close open filter panel when opening another grid filter' or 'Fix filter panel isolation in shadow DOM contexts'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/close-multigrid-filter

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 and usage tips.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 93cba6da73

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/plugins/filter/filter.panel.tsx Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
src/plugins/filter/filter.panel.tsx (1)

663-678: 💤 Low value

Remove unnecessary type assertion.

After the instanceof Element check on line 664, TypeScript already narrows target to Element. The explicit cast on line 668 is redundant.

Suggested fix
 private isOwnFilterButton(target: EventTarget | null) {
   if (!(target instanceof Element)) {
     return false;
   }

-  const element = target as Element;
-
-  if (!isFilterBtn(element)) {
+  if (!isFilterBtn(target)) {
     return false;
   }

   const panelGrid = this.getOwningGrid(this.element);
-  const targetGrid = this.getOwningGrid(element);
+  const targetGrid = this.getOwningGrid(target);

   return !!panelGrid && panelGrid === targetGrid;
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/plugins/filter/filter.panel.tsx` around lines 663 - 678, In
isOwnFilterButton, remove the redundant type assertion "const element = target
as Element" because the preceding "if (!(target instanceof Element))" already
narrows target to Element; instead use the narrowed variable directly (e.g.,
rename or reuse "target" as the Element) when calling isFilterBtn,
getOwningGrid, and comparing panelGrid/targetGrid in the isOwnFilterButton
method to eliminate the unnecessary cast.

Source: Linters/SAST tools

e2e/filtering.spec.ts (1)

124-134: 💤 Low value

Consider using the withHeaderTestId helper for consistency.

The column configuration uses columnProperties: () => ({ 'data-testid': ... }) directly, while other tests in this file use the withHeaderTestId helper. Using the helper would improve consistency.

♻️ Proposed refactor
         {
           prop: 'role',
           name: 'Role',
           filter: true,
-          columnProperties: () => ({ 'data-testid': `${prefix}-filter-role` }),
+          ...withHeaderTestId(`${prefix}-filter-role`),
         },
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e/filtering.spec.ts` around lines 124 - 134, Replace the inline
columnProperties for the "role" column with the shared helper: use
withHeaderTestId to attach the header test id instead of columnProperties: () =>
({ 'data-testid': `${prefix}-filter-role` }); update the grid.columns entry for
the column with prop 'role' (and keep filter: true and name: 'Role') to call
withHeaderTestId(prefix, 'filter-role') (or the existing helper signature) so
the test id pattern and consistency match other tests that use withHeaderTestId.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@e2e/filtering.spec.ts`:
- Around line 124-134: Replace the inline columnProperties for the "role" column
with the shared helper: use withHeaderTestId to attach the header test id
instead of columnProperties: () => ({ 'data-testid': `${prefix}-filter-role` });
update the grid.columns entry for the column with prop 'role' (and keep filter:
true and name: 'Role') to call withHeaderTestId(prefix, 'filter-role') (or the
existing helper signature) so the test id pattern and consistency match other
tests that use withHeaderTestId.

In `@src/plugins/filter/filter.panel.tsx`:
- Around line 663-678: In isOwnFilterButton, remove the redundant type assertion
"const element = target as Element" because the preceding "if (!(target
instanceof Element))" already narrows target to Element; instead use the
narrowed variable directly (e.g., rename or reuse "target" as the Element) when
calling isFilterBtn, getOwningGrid, and comparing panelGrid/targetGrid in the
isOwnFilterButton method to eliminate the unnecessary cast.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d0d20c13-a749-48d2-aa67-1b73a69d2a8c

📥 Commits

Reviewing files that changed from the base of the PR and between 93cba6d and 60aa488.

📒 Files selected for processing (3)
  • e2e/filtering.spec.ts
  • src/plugins/filter/filter.button.tsx
  • src/plugins/filter/filter.panel.tsx
✅ Files skipped from review due to trivial changes (1)
  • src/plugins/filter/filter.button.tsx

@sonarqubecloud

Copy link
Copy Markdown

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.

2 participants