Skip to content

Table block: Keep table actions enabled after deleting a row or column#78962

Open
Mayank-Tripathi32 wants to merge 1 commit into
WordPress:trunkfrom
Mayank-Tripathi32:fix/28714-table-edit-actions
Open

Table block: Keep table actions enabled after deleting a row or column#78962
Mayank-Tripathi32 wants to merge 1 commit into
WordPress:trunkfrom
Mayank-Tripathi32:fix/28714-table-edit-actions

Conversation

@Mayank-Tripathi32
Copy link
Copy Markdown
Member

What?

Closes #28714 - independent Testing required, Please do not merge.

After deleting a row or column in the Table block, the "Edit table" menu actions (Insert/Delete row/column) became disabled until the user clicked a cell again to refocus. This PR keeps a sensible cell selected after the deletion, so the actions stay usable.

Why?

onDeleteRow and onDeleteColumn were calling setSelectedCell() (clearing the selection) and then setting the new attributes. Every item in tableControls uses isDisabled: ! selectedCell, so the whole menu greyed out until focus returned to a cell. The reporter (and several follow-up confirmations across multiple WP/Gutenberg versions) all had to click a cell to perform a second edit.

How?

Mirrors the pattern already used by onInsertRow / onInsertColumn: after mutating the attributes, select a cell that still exists.

  • Row delete: select the cell at the same columnIndex, with rowIndex clamped to the new section length. If the section is empty after the delete, clear the selection.
  • Column delete: select the cell at the same sectionName / rowIndex, with columnIndex clamped to the new column count (using getFirstRow to read it). If no columns remain, clear.

Testing Instructions

  1. Add a Table block, set rows ≥ 2 and columns ≥ 2, click "Create Table".
  2. Click a body cell once.
  3. Block toolbar → "Edit table" → "Delete row".
  4. Open "Edit table" again — the actions should still be enabled (before this PR they were greyed out until you refocused a cell).
  5. Same for "Delete column".

E2E coverage is added in test/e2e/specs/editor/blocks/table.spec.js as a regression test.

Testing Instructions for Keyboard

No keyboard-interaction changes. The same regression test exercises the menu after both row and column deletion.

Ai Usage?

  • Yes, Claude

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Mayank-Tripathi32 <mayanktripathi32@git.wordpress.org>
Co-authored-by: skorasaurus <skorasaurus@git.wordpress.org>
Co-authored-by: kathrynwp <zoonini@git.wordpress.org>
Co-authored-by: inaikem <inaikem@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions Bot added the [Package] Block library /packages/block-library label Jun 4, 2026
@t-hamano t-hamano added [Type] Enhancement A suggestion for improvement. [Block] Table Affects the Table Block labels Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Table Affects the Table Block [Package] Block library /packages/block-library [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Table block] Edit table actions are unclickable after inserting a new table

2 participants