Skip to content

fix(table): register tab shortcuts and add table cell navigation (#5065) - #5076

Closed
Samarth1306w wants to merge 1 commit into
udecode:nextfrom
Samarth1306w:fix/table-tab-cell-navigation-5065
Closed

fix(table): register tab shortcuts and add table cell navigation (#5065)#5076
Samarth1306w wants to merge 1 commit into
udecode:nextfrom
Samarth1306w:fix/table-tab-cell-navigation-5065

Conversation

@Samarth1306w

@Samarth1306w Samarth1306w commented Aug 5, 2026

Copy link
Copy Markdown
  • Auto release

🎯 Summary

Fixes #5065 — Tab and Shift+Tab leave table cells instead of navigating between cells.

🔍 Root Cause Analysis

When Tab or Shift+Tab was pressed inside a table cell (where cell text resides inside a paragraph element), BaseIndentPlugin's shortcut handler intercepted the native DOM keydown event prior to React's onKeyDown in TablePlugin. indent.tab() indented the paragraph inside the cell and called event.preventDefault(). When React's onKeyDown in TablePlugin fired, it saw event.defaultPrevented and bailed out immediately, preventing cell navigation. Furthermore, pressing Tab in the last cell of a table did not append a new row.

🛠️ Surgical Patch Breakdown

  1. packages/table/src/lib/BaseTablePlugin.ts:
    • Register explicit tab and untab shortcuts on BaseTablePlugin with high priority (priority: 100).
    • Update update.tab to append a new row when pressing Tab in the last cell of a table (when disableExpandOnInsert is false).
    • Add untab shortcut handler mapping to tab({ reverse: true }).
  2. packages/indent/src/lib/BaseIndentPlugin.ts:
    • Guard indent.tab() and indent.untab() so they yield (return false) when selection is inside a table cell (td / th).
  3. .changeset/fix-table-tab-cell-navigation.md: Added patch changeset for @platejs/table and @platejs/indent.

🧪 Verification & Test Coverage

  • Shortcut Interception Test: Verified BaseTablePlugin's shortcuts intercept Tab/Shift+Tab and navigate between cells, appending a new row when pressing Tab in the last cell.
  • Changeset Included: Patch changeset generated for @platejs/table and @platejs/indent.
  • Clean Merge: Branch rebased cleanly against next with 0 conflicts.

When Tab or Shift+Tab was pressed inside a table cell, BaseIndentPlugin's
shortcuts intercepted the event before TablePlugin's onKeyDown handler fired,
indenting the paragraph block inside the cell and leaving the table context.

Fix:
- Register tab and untab shortcuts on BaseTablePlugin with priority 100.
- Update update.tab to insert a new row when pressing Tab in the last table cell.
- Guard BaseIndentPlugin tab/untab so they yield when selection is inside a table cell.
- Add patch changeset for @platejs/table and @platejs/indent.

Closes #5065
@codesandbox

codesandbox Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Aug 5, 2026
@changeset-bot

changeset-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 041b4e0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@platejs/table Patch
@platejs/indent Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dosubot dosubot Bot added bug Something isn't working patch Bugfix & documentation PR plugin:indent plugin:table Tables labels Aug 5, 2026
@zbeyens zbeyens closed this Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working patch Bugfix & documentation PR plugin:indent plugin:table Tables size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants