You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(utils): only match null with null in compare - #7441
📖 Documentation (updates to the documentation or readme)
🐞 Bug fix (a non-breaking change that fixes an issue)
👌 Enhancement (improving an existing functionality)
✨ New feature (a non-breaking change that adds functionality)
🧹 Chore (updates to the build process or auxiliary tools and libraries)
⚠️ Breaking change (fix or feature that would cause existing functionality to change)
📚 Description
Noticed while reviewing #7437. With by="value" and a null model value, for example after clear, a SelectMenu with grouped items showed the first group label as the selected value. A by function was also called with null and threw.
AssertionError: expected 'Status' to be undefined
This was because the string comparator in compare reads the path on both sides, and get(labelItem, 'value') and get(null, 'value') are both undefined. So null now only matches null, which keeps items like { label: 'None', value: null } working.
No actionable comments were generated in the recent review.
Walkthrough
The compare utility now handles null values before its string, comparator and deep-equality checks. It returns true only when both values are null. Tests cover null comparisons with string-path and function comparators, and a null value in getDisplayValue when matching by value.
This change stops a null model value from matching an unrelated item when comparing by a path or function. Items whose own value is null still match a null model value. The change is small, tested, and low risk to merge.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the actual change: compare now matches null only with null. It also gives the conventional-commit type fix(utils). The change summary confirms that compare in `src/runtime/ut…
Description check
The description explains the bug: with by="value" and a null model value, a grouped SelectMenu showed the wrong selected label, and a by function threw. It names the cause, the string comparat…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the actual change: compare now matches null only with null. It also gives the conventional-commit type fix(utils). The change summary confirms that compare in src/runtime/utils/index.ts now handles null before its other checks, which matches the title.
Full details: Description check
Explanation
The description explains the bug: with by="value" and a null model value, a grouped SelectMenu showed the wrong selected label, and a by function threw. It names the cause, the string comparator reading the path on both sides, and the fix, so null only matches null. The added tests and the compare change in the summary relate directly to this.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Reviewing files that changed from the base of the PR and between 550471d and 27e7ff9.
Files selected for processing: 2
src/runtime/utils/index.ts
test/utils/index.spec.ts
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 3 remain after this review.
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
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.
🔗 Linked issue
❓ Type of change
📚 Description
Noticed while reviewing #7437. With
by="value"and anullmodel value, for example afterclear, aSelectMenuwith grouped items showed the first group label as the selected value. Abyfunction was also called withnulland threw.This was because the string comparator in
comparereads the path on both sides, andget(labelItem, 'value')andget(null, 'value')are bothundefined. Sonullnow only matchesnull, which keeps items like{ label: 'None', value: null }working.📝 Checklist