fix(table): register tab shortcuts and add table cell navigation (#5065) - #5076
Closed
Samarth1306w wants to merge 1 commit into
Closed
fix(table): register tab shortcuts and add table cell navigation (#5065)#5076Samarth1306w wants to merge 1 commit into
Samarth1306w wants to merge 1 commit into
Conversation
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
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
🦋 Changeset detectedLatest commit: 041b4e0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 Summary
Fixes #5065 — Tab and Shift+Tab leave table cells instead of navigating between cells.
🔍 Root Cause Analysis
When
TaborShift+Tabwas pressed inside a table cell (where cell text resides inside a paragraph element),BaseIndentPlugin's shortcut handler intercepted the native DOMkeydownevent prior to React'sonKeyDowninTablePlugin.indent.tab()indented the paragraph inside the cell and calledevent.preventDefault(). When React'sonKeyDowninTablePluginfired, it sawevent.defaultPreventedand bailed out immediately, preventing cell navigation. Furthermore, pressingTabin the last cell of a table did not append a new row.🛠️ Surgical Patch Breakdown
packages/table/src/lib/BaseTablePlugin.ts:tabanduntabshortcuts onBaseTablePluginwith high priority (priority: 100).update.tabto append a new row when pressingTabin the last cell of a table (whendisableExpandOnInsertis false).untabshortcut handler mapping totab({ reverse: true }).packages/indent/src/lib/BaseIndentPlugin.ts:indent.tab()andindent.untab()so they yield (returnfalse) when selection is inside a table cell (td/th)..changeset/fix-table-tab-cell-navigation.md: Added patch changeset for@platejs/tableand@platejs/indent.🧪 Verification & Test Coverage
BaseTablePlugin's shortcuts interceptTab/Shift+Taband navigate between cells, appending a new row when pressingTabin the last cell.@platejs/tableand@platejs/indent.nextwith 0 conflicts.