Skip to content

fix(state): avoid ambiguous Map keys during edits - #1169

Open
shuaiyafei wants to merge 1 commit into
vuejs:mainfrom
shuaiyafei:fix/map-rename-preview-collisions
Open

shuaiyafei wants to merge 1 commit into
vuejs:mainfrom
shuaiyafei:fix/map-rename-preview-collisions

Conversation

@shuaiyafei

Copy link
Copy Markdown
Contributor

Summary

Use the same preview-label rules for creating Map keys that state-path resolution already uses.

For example, a Map can contain the numeric key 1. Renaming a different entry to the string "1" previously passed Map.has("1"), wrote the new value, and created a second key with the same displayed label. Subsequent state-path resolution rejects that label as ambiguous, so neither entry can be edited or deleted through the inspector.

The fix checks existing preview labels before writing, preserving the original values and reactive effects when a rename is rejected. The rename helper applies the same guard.

Automatic key generation also checks preview labels: an existing Symbol("newProp1") reserves that display name, so a new entry gets the next available name. Its label set is built once per addition.

Coverage

  • Reject rename collisions with number, boolean, bigint, symbol, object, null, and undefined keys.
  • Preserve values and avoid reactive notifications on a rejected edit.
  • Keep successful renames of non-string keys working.
  • Generate an unambiguous automatic key alongside existing symbol/string labels.

The collision cases failed before the corresponding fixes.

Validation

  • pnpm lint
  • pnpm test: 415 tests passed across 67 files
  • pnpm typecheck
  • pnpm build

@netlify

netlify Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for vue-devtools-docs canceled.

Name Link
🔨 Latest commit 6e08b23
🔍 Latest deploy log https://app.netlify.com/projects/vue-devtools-docs/deploys/6ad2e664d4bec684a4068b18

@pkg-pr-new

pkg-pr-new Bot commented Oct 17, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@vue/devtools-agent@1169
npm i https://pkg.pr.new/@vue/devtools-api@1169
npm i https://pkg.pr.new/@vue/devtools-kit@1169
npm i https://pkg.pr.new/vite-plugin-vue-devtools@1169

commit: 6e08b23

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant