Skip to content

[WC-3634]: Show the Rich Text table toolbar with the advanced custom toolbar - #2491

Open
samuelreichert wants to merge 1 commit into
mainfrom
fix/rich-text-advanced-table-toolbar
Open

samuelreichert wants to merge 1 commit into
mainfrom
fix/rich-text-advanced-table-toolbar

Conversation

@samuelreichert

Copy link
Copy Markdown
Contributor

Pull request type

Bug fix (non-breaking change which fixes an issue)


Description

With Custom toolbar set to Advanced and a Table item in the advanced groups, the Insert table button appeared, but the table toolbar (Table configuration, Cell configuration, merge/split, …) never showed when the cursor was inside a table. It worked with the Basic custom toolbar and with the presets.

Root cause: buildAdvancedToolbar regroups the configured buttons under generated names (custom-group-N). The toolbar only rendered the table-operations secondary group when a filtered group was named exactly tableBetter, so in Advanced mode it was always filtered out.

Fix: a new getSecondaryToolbarGroups helper in ToolbarConfig.ts includes a secondary group when any button of its parent group is present, matching by button name instead of group name. This works the same for presets, the Basic custom toolbar and the Advanced custom toolbar.

The change was written test-first: the new runtime test for the Advanced toolbar failed before the fix. The package test suite passes (611 tests), and there is a CHANGELOG entry under [Unreleased].

What should be covered while testing?

  1. Set Toolbar to Custom and Custom toolbar to Advanced, and add a Table item to the advanced groups (with or without other items and separators).
  2. Insert a table and put the cursor in a cell. The table toolbar appears.
  3. Move the cursor out of the table. The table toolbar disappears.
  4. Remove the Table item. The table toolbar no longer appears, even inside an existing table.
  5. Check that the Basic custom toolbar (Table enabled) and the Standard/Full presets still show the table toolbar inside a table.

🤖 Generated with Claude Code

…oolbar

The advanced custom toolbar regroups buttons under generated group names,
so the table operations toolbar never matched its "tableBetter" parent
group. Match secondary groups by the parent group's buttons instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@samuelreichert
samuelreichert requested a review from a team as a code owner October 23, 2026 17:21
@github-actions

Copy link
Copy Markdown
Contributor

AI Code Review

✅ Approved — no issues found


What was reviewed

File Change
packages/pluggableWidgets/rich-text-web/CHANGELOG.md Added [Unreleased] → Fixed entry for the table toolbar regression
packages/pluggableWidgets/rich-text-web/src/components/toolbars/ToolbarConfig.ts New getSecondaryToolbarGroups helper — matches secondary groups by button name instead of parent group name
packages/pluggableWidgets/rich-text-web/src/components/toolbars/Toolbar.tsx Replaced inline filter logic with call to getSecondaryToolbarGroups; removed SECONDARY_TOOLBAR_GROUP import
packages/pluggableWidgets/rich-text-web/src/components/toolbars/helpers/__tests__/ToolbarConfig.spec.ts Unit tests for getSecondaryToolbarGroups covering preset, advanced-with-table, and advanced-without-table cases
packages/pluggableWidgets/rich-text-web/src/__tests__/RichText.runtime.spec.tsx Integration-level tests for the table toolbar in basic and advanced custom toolbar modes

Skipped (out of scope): dist/, pnpm-lock.yaml


Positives

  • Written test-first: the failing runtime test is added in the same commit and directly demonstrates the bug before the fix.
  • Root-cause analysis in the PR description is precise and correct — buildAdvancedToolbar generates custom-group-N names, so the old name-based match could never succeed in advanced mode.
  • getSecondaryToolbarGroups is extracted as a pure, exported function instead of keeping the logic inline, making it independently testable and reusable.
  • The button-name lookup uses a Set (buttonNames) instead of nested find/includes — O(n) rather than O(n²) over buttons.
  • All three toolbar modes (preset, basic custom, advanced custom) are covered by the new unit tests.
  • CHANGELOG entry is user-facing behaviour only — no implementation details.
  • SECONDARY_TOOLBAR_GROUP import correctly removed from Toolbar.tsx now that it is encapsulated in the helper.

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