Repository navigation
fix: fix the filter error in dataset page - #17734
Conversation
📝 WalkthroughWalkthroughThe list filter bar now treats missing or nullish nested filter lengths as zero during count aggregation. ChangesFilter Count Safety
Estimated code review effort: 1 (Trivial) | ~2 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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. Comment |
wangq8
left a comment
There was a problem hiding this comment.
Thanks for the fix! This is a clean, minimal defensive fix.
What the code does: Inside ListFilterBar's filterCount memo, when value is a nested object (e.g. filter groups), it counts total active filter items by summing .length on each inner value. The original code pre + cur.length would throw a TypeError if any inner value was null/undefined.
The fix: cur?.length || 0 safely returns 0 when cur is nullish, while still correctly counting array lengths otherwise.
Review:
- ✅ Correct — optional chaining +
|| 0is the right pattern here. - ✅ No regressions — empty arrays still yield 0 (falsy
.length→0 || 0= 0), non-empty arrays yield correct counts. - ✅ Minimal scope — 1 line changed, 1 file.
- ✅ No security concerns, no missing test concerns (purely defensive null-guard in a UI component).
LGTM 🚀
Summary
fix: fix the filter error in dataset page