Skip to content

fix(Table): accept readonly arrays in data prop - #7412

Open
lazerg wants to merge 1 commit into
nuxt:v4from
lazerg:fix/issue-7411-table-readonly-data
Open

lazerg wants to merge 1 commit into
nuxt:v4from
lazerg:fix/issue-7411-table-readonly-data

Conversation

@lazerg

@lazerg lazerg commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

🔗 Linked issue

Resolves #7411

❓ 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

The data prop was typed as T[], so a readonly array (from readonly(), a computed<readonly T[]> or a query cache) failed to type check, even though the table never mutates it. Callers had to cast or pass [...data].

The prop is now readonly T[]. TanStack still wants a mutable TData[], so the internal ref starts from a copy, the same thing the props.data watcher already does on every update. Mutable arrays keep working as before.

📝 Checklist

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

@vercel

vercel Bot commented Nov 14, 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 14, 2026 9:30am UTC
ui-repl Ready Ready Preview Nov 14, 2026 9:30am UTC

Request 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 906.8 kB (+1 B, +0.0%) 29.3 kB
Raw sizes
Fixture JS CSS
nuxt-full 2843.8 kB (+11 B, +0.0%) 212.3 kB

@coderabbitai

coderabbitai Bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The table’s data prop now accepts readonly arrays. The component copies supplied data into its internal ref during initialisation. A test mounts the table with readonly data and checks that the rendered body-row count matches the data length.

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

Severity of issue fixed: Low

Merge Risk: Minimal · up to 0222a

The UTable data prop now accepts readonly arrays, and the table copies the rows internally, so the caller's array is not modified. Existing mutable-array usage keeps working. No actionable merge risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the Table component's data prop now accepts readonly arrays. It follows the conventional commit format and fits the linked issue #7411 and the changeset.
Description check Passed The description explains the change. It states that the data prop changed from T[] to readonly T[], that the internal ref now starts from a copy because TanStack requires a mutable array, and that it …
Linked Issues check Passed Issue #7411 requires the UTable data prop to accept readonly arrays and requires the internal state to start from a copy, because TanStack Table types data as mutable. At the reviewed head, `src…
Out of Scope Changes check Passed The PR changes two files only. src/runtime/components/Table.vue changes the data prop type and the initial ref creation, which are the two changes the issue requests. `test/components/Table.spec.t…
Full details: Description check

Explanation

The description explains the change. It states that the data prop changed from T[] to readonly T[], that the internal ref now starts from a copy because TanStack requires a mutable array, and that it links issue #7411. It is related to the changeset.

Full details: Linked Issues check

Explanation

Issue #7411 requires the UTable data prop to accept readonly arrays and requires the internal state to start from a copy, because TanStack Table types data as mutable. At the reviewed head, src/runtime/components/Table.vue declares data?: readonly T[] (was T[]). The initial internal ref is created from props.data ? [...props.data] : [], which matches the proposed change in the issue. The existing props.data watcher already copies on update, so the readonly-to-mutable boundary holds for initialisation and updates. Mutable arrays still work, because a copy of a mutable array is also a valid input. test/components/Table.spec.ts adds an automated test, 'accepts readonly data', which mounts Table with readonly(data) and checks the rendered tbody tr count against data.length. The issue has no non-coding requirements. The PR description and the issue agree. Evidence was taken from the whole-PR diff against the merge base. I did not run the test suite. The diff does not show a regression path for the watcher or the createRef deep option.

Full details: Out of Scope Changes check

Explanation

The PR changes two files only. src/runtime/components/Table.vue changes the data prop type and the initial ref creation, which are the two changes the issue requests. test/components/Table.spec.ts adds the readonly import and one test for the new behaviour. Both changes support the linked objective. No unrelated refactoring, documentation, or configuration change appears in the diff. The PR description has an unchecked documentation item, but no documentation change is required by the issue's coding scope.

  • 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: 9a7324a3-a84f-4acc-8ee2-d91c8ac1ce58
Commits

Reviewing files that changed from the base of the PR and between 3879d26 and 0222a56.

Files selected for processing: 2

  • src/runtime/components/Table.vue
  • test/components/Table.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@pkg-pr-new

pkg-pr-new Bot commented Nov 14, 2026

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

commit: 0222a56

@codspeed

codspeed Bot commented Nov 14, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 33 untouched benchmarks
⏩ 10 skipped benchmarks1


Comparing lazerg:fix/issue-7411-table-readonly-data (0222a56) with v4 (3879d26)

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. ↩

This branch was successfully deployed

2 active deployments
Preview – ui — 0222a563 Deployed Nov 14, 2026 by vercel[bot]
Preview – ui-repl — 0222a563 Deployed Nov 14, 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.

Table: accept readonly arrays in the data prop

1 participant