Skip to content

fix(toolbar): give each toolbar separator its own item - #3931

Closed
PopaSerban wants to merge 2 commits into
superdoc:mainfrom
PopaSerban:fix/toolbar-separator-duplicate-key
Closed

PopaSerban wants to merge 2 commits into
superdoc:mainfrom
PopaSerban:fix/toolbar-separator-duplicate-key

Conversation

@PopaSerban

@PopaSerban PopaSerban commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Fix a Vue "Duplicate keys found during update" warning on ButtonGroup by giving
    each separator in the built-in toolbar its own item, instead of reusing one
    shared item six times (packages/superdoc/src/internal/toolbar/built-in/default-items.js).
    UI layer only — no pipeline/document-data involvement.
Duplicate keys warning

Context

ButtonGroup.vue keys its v-for on item.id.value. default-items.js created a
single separator toolbar item and spliced that same object into the toolbar list
six times; since separators default to the center group, all six ended up in one
ButtonGroup sharing one id, so Vue re-render passes for that group patched a
list with six duplicate keys.

The warning only surfaces on a re-render after the initial mount (Vue's duplicate-key
check runs in patchKeyedChildren, not on first mount), which is why it doesn't show
up right after page load — it needs a toolbar-state-change event (e.g. clicking
into the document, changing selection, typing) to trigger the re-render.

Fix: default-items.js now calls useToolbarItem(...) fresh for each separator
occurrence, giving each its own id.

File Change Risk
packages/superdoc/src/internal/toolbar/built-in/default-items.js shared separator item → makeSeparator() factory, called at each of its 6 use sites LOW — internal to the module, no exported signature change

`ButtonGroup.vue` keys its v-for on item.id.value. default-items.js
created a single `separator` item and reused that same object six
times in the toolbar list; since separators default to the "center"
group, all six landed in one ButtonGroup sharing one id, so a
re-render for that group patched a list with six duplicate keys
(Vue's "Duplicate keys found during update" warning).

Each separator occurrence now gets its own item via makeSeparator().
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@PopaSerban

Copy link
Copy Markdown
Contributor Author

Closing to reopen with a clean branch (no merge commit) — see replacement PR.

@PopaSerban PopaSerban closed this Aug 25, 2026
@PopaSerban
PopaSerban deleted the fix/toolbar-separator-duplicate-key branch August 25, 2026 17:17
superdoc-bot Bot pushed a commit that referenced this pull request Oct 22, 2026
…elper (#3931)

* refactor(superdoc): read UI host methods through a typed hostMethod helper

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(superdoc): record the Document API boundary counts the hostMethod refactor removes

Reading `editCommands` and `getHandles` through `hostMethod` removes four
`editCommands` references and one `getHandles(` call site from
create-super-doc-ui.ts. The boundary inventory is an exact match, so a
removal fails until it is recorded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(superdoc): count a host method the Document API guard reads by name

`hostMethod(getHost(), 'getHandles')` moves the member name into a string,
so the handles route stopped seeing two access points that are still
bypasses. Count the quoted form, and rename the local binding in
mirrorTrackedChangeFocusToHost so that site counts once rather than twice.

The handles baseline returns to 16. editCommands stays at 13, which is
fewer mentions of a local variable, not a removed access point.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(superdoc): pin the host-call behavior the hostMethod refactor routes through

Covers the paths the preflight check found untested, with fake hosts built
the way the neighboring tests build them:

- A class-based host whose getTableContext is a prototype method reading a
  private field, returning a snapshot that is not an object literal. This
  pins the Reflect.apply receiver and shows isPlainObject accepts a
  non-Object.prototype snapshot.
- contextMenu.open reporting operation-unavailable for a missing surface,
  a surface without open, and a non-callable open; forwarding a known host
  reason and falling back for an unknown one; close swallowing a throwing
  surface.
- The host review handle needing both getActiveReviewTarget and
  clearActiveReviewTarget before either is called.
- selection.restore re-applying a well-formed captured cell target as a
  cell selection, and rejecting malformed points with target-unresolved
  without reaching the host.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Ported-From-Source-Repo: superdoc/orbit
Ported-From-Source-Commit: 6afe4b3dd0e92c65d017a90e583dd1408bc182a9
Ported-Public-Prefix: superdoc/public
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant