Skip to content

fix(utils): only match null with null in compare - #7441

Merged
benjamincanac merged 1 commit into
v4from
fix/compare-null
Nov 18, 2026
Merged

benjamincanac merged 1 commit into
v4from
fix/compare-null

Conversation

@benjamincanac

Copy link
Copy Markdown
Member

🔗 Linked issue

❓ Type of change

  • 📖 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.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@vercel

vercel Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ui Ready Ready Preview Nov 18, 2026 10:54am UTC
ui-repl Ready Ready Preview Nov 18, 2026 10:54am UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

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.

Estimated code review effort: 2 (Simple) | ~5 minutes

Merge Risk: Minimal · up to 27e7f

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: Passed 4

Check name Status Explanation
Title check Passed 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 Passed 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 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.
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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 34af9d4a-df33-4ee3-a8dc-0ecff7d31868
Commits

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.

@github-actions

Copy link
Copy Markdown

Client output of the apps in test/bundle that changed, compared to the base branch.

Fixture JS (gzip) CSS (gzip)
nuxt-full 907.2 kB (+0.2 kB, +0.0%) 29.3 kB
Raw sizes
Fixture JS CSS
nuxt-full 2844.4 kB (+20 B, +0.0%) 212.3 kB

@codspeed

codspeed Bot commented Nov 18, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 33 untouched benchmarks
⏩ 10 skipped benchmarks1


Comparing fix/compare-null (27e7ff9) with v4 (550471d)

Open in CodSpeed

Footnotes

  1. 10 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@pkg-pr-new

pkg-pr-new Bot commented Nov 18, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/@nuxt/ui@7441

commit: 27e7ff9

@benjamincanac
benjamincanac merged commit 073be5e into v4 Nov 18, 2026
35 checks passed
@benjamincanac
benjamincanac deleted the fix/compare-null branch November 18, 2026 11:27

This branch was successfully deployed

2 active deployments
Preview – ui — 27e7ff92 Deployed Nov 18, 2026 by vercel[bot]
Preview – ui-repl — 27e7ff92 Deployed Nov 18, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v4 #4488

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant