Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: filter count badge displaying incorrect count for empty filters#3882

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
dhruv-suthar wants to merge3 commits intorequestly:master
base:master
Choose a base branch
Loading
fromdhruv-suthar:fix/incorrect-filter-count

Conversation

@dhruv-suthar
Copy link

@dhruv-suthardhruv-suthar commentedNov 19, 2025
edited by coderabbitaibot
Loading

Closes issue:#3826

📜 Summary of changes:

  • Fixed the bug where rules incorrectly displayed "1 applied filter" even when no filters were configured. The issue occurred when:

✅ Checklist:

  • Make sure linting and unit tests pass.
  • No install/build warnings introduced.
  • Verified UI in browser.
  • For UI changes, added/updated analytics events (if applicable). - N/A (bug fix, no new events)
  • For changes in extension's code, manually tested in Chrome and Firefox. - N/A (web app change)
  • Added/updated unit tests for this change. - Recommended but not included in this PR
  • Raised pull request to update corresponding documentation (if already exists). - N/A
  • Added demo video showing the changes in action (if applicable). - See above

🎥 Demo Video:

Video/Demo:
https://github.com/user-attachments/assets/375d55df-f994-4be0-ba42-db5abd519d85

Summary by CodeRabbit

Bug Fixes

  • Fixed filter count calculation logic to accurately display results across all filter configurations and edge cases.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign ourContributor License Agreement before we can accept your contribution.


dhruv-suthar seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, pleaseadd the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let usrecheck it.

@coderabbitai
Copy link
Contributor

coderabbitaibot commentedNov 19, 2025
edited
Loading

Walkthrough

ThegetFilterCount function has been refactored to compute filter counts from a normalized filters object. The new implementation uses a definedCOUNTABLE_FILTERS set containing REQUEST_METHOD, RESOURCE_TYPE, and PAGE_DOMAINS, counting only those filters that are arrays with length greater than 0. Defensive checks now handle missing or invalid filter objects, and optional chaining is used for the upgraded format path. This replaces the previous key-counting approach that had special handling for page URL exclusion.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify theCOUNTABLE_FILTERS set captures all relevant filter types previously counted
  • Confirm optional chaining correctly handles missing nested fields in the upgraded format path
  • Validate that defensive checks adequately cover edge cases for null, undefined, or malformed filter objects
  • Ensure the new logic produces equivalent results to the previous key-counting approach for existing use cases

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check nameStatusExplanationResolution
Description check❓ InconclusiveThe description includes the issue link, a summary of changes, a demo video, and a completed checklist, but the summary section is incomplete with ellipsis where details should be.Complete the 'Summary of changes' section by explaining the specific conditions that caused the bug and detailing how the fix addresses them.
✅ Passed checks (2 passed)
Check nameStatusExplanation
Title check✅ PassedThe title directly summarizes the main bug fix: correcting an incorrect filter count display for empty filters, which matches the changeset's core objective.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for usingCodeRabbit! 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.

Copy link
Contributor

@coderabbitaicoderabbitaibot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
app/src/components/features/rules/RulePairs/Pairs/Rows/RowsMarkup/RequestSourceRow/index.js (1)

83-87:Consider moving COUNTABLE_FILTERS outside the callback.

The constant is recreated on every render insideuseCallback. Since it's static, moving it outside the component (or at least outside the callback) would improve performance slightly.

Move the constant to module scope:

+const COUNTABLE_FILTERS = [+  GLOBAL_CONSTANTS.RULE_SOURCE_FILTER_TYPES.REQUEST_METHOD,+  GLOBAL_CONSTANTS.RULE_SOURCE_FILTER_TYPES.RESOURCE_TYPE,+  GLOBAL_CONSTANTS.RULE_SOURCE_FILTER_TYPES.PAGE_DOMAINS,+];+ const RequestSourceRow = ({ rowIndex, pair, pairIndex, ruleDetails, isInputDisabled }) => {

And remove lines 83-87 from inside the callback.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between215d810 and1fc64c5.

📒 Files selected for processing (1)
  • app/src/components/features/rules/RulePairs/Pairs/Rows/RowsMarkup/RequestSourceRow/index.js (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
app/src/components/features/rules/RulePairs/Pairs/Rows/RowsMarkup/RequestSourceRow/index.js (2)
app/src/components/features/rules/RulePairs/Filters/index.jsx (1)
  • currentlySelectedRuleData (65-65)
app/src/components/features/rules/RulePairs/index.js (1)
  • currentlySelectedRuleData (18-18)
🔇 Additional comments (2)
app/src/components/features/rules/RulePairs/Pairs/Rows/RowsMarkup/RequestSourceRow/index.js (2)

73-79:LGTM! Solid defensive checks.

The filter retrieval logic correctly handles both upgraded and legacy formats with optional chaining, and the type guard prevents errors when filters are missing or invalid. This directly addresses the bug where empty filters would display an incorrect count.


89-92:Excellent fix for the filter count bug!

The logic correctly counts only non-empty array filters by explicitly checkingArray.isArray(value) && value.length > 0. This fixes the bug where empty filters would incorrectly display "1 applied filter" by ensuring only populated filters contribute to the count.

@dinex-devdinex-dev linked an issueNov 20, 2025 that may beclosed by this pull request
4 tasks
Copy link
Contributor

@nafees87nnafees87n left a comment

Choose a reason for hiding this comment

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

Looks good to be merged
Thanks for the PR@dhruv-suthar.

@nafees87n
Copy link
Contributor

@dhruv-suthar Please sign theCLA here so that the PR can be merged

@dhruv-suthar
Copy link
Author

@dhruv-suthar Please sign theCLA here so that the PR can be merged

@nafees87n done signed.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@coderabbitaicoderabbitai[bot]coderabbitai[bot] left review comments

@nafees87nnafees87nnafees87n approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

bug: Rule shows “1 applied filter” even when no filter is applied

3 participants

@dhruv-suthar@CLAassistant@nafees87n

[8]ページ先頭

©2009-2025 Movatter.jp