Skip to content

Fix prompt keyboard navigation inside tables#718

Open
yanfroes wants to merge 4 commits intobasecamp:mainfrom
yanfroes:fix-keyboard-navigation-table
Open

Fix prompt keyboard navigation inside tables#718
yanfroes wants to merge 4 commits intobasecamp:mainfrom
yanfroes:fix-keyboard-navigation-table

Conversation

@yanfroes
Copy link

@yanfroes yanfroes commented Feb 4, 2026

Fixes #677

Problem
When using @ mentions (or other prompts) inside a table cell, pressing arrow keys navigates between table cells instead of navigating the dropdown options.

Cause
Lexical's table plugin registers arrow key handlers at COMMAND_PRIORITY_HIGH during editor initialization. The prompt also registered its handlers at the same priority, but later—causing table handlers to intercept keyboard events first.

Solution
Changed prompt key handlers from COMMAND_PRIORITY_HIGH to COMMAND_PRIORITY_CRITICAL, ensuring they take precedence over table navigation when the prompt is open.

lexxy-fix-prompt-keyboard-navigation-inside-tables.mp4

When a prompt (e.g., @ mentions) is open inside a table cell, arrow keys
should navigate the dropdown options, not the table cells.

Changed prompt key handlers from COMMAND_PRIORITY_HIGH to
COMMAND_PRIORITY_CRITICAL so they run before table navigation handlers.

Fixes basecamp#677
Copilot AI review requested due to automatic review settings February 4, 2026 22:35
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes keyboard navigation for prompt dropdowns (e.g., @ mentions) when used inside table cells by changing the priority of keyboard event handlers from COMMAND_PRIORITY_HIGH to COMMAND_PRIORITY_CRITICAL.

Changes:

  • Updated keyboard command registration priorities in prompt.js from COMMAND_PRIORITY_HIGH to COMMAND_PRIORITY_CRITICAL for all key handlers (ENTER, TAB, SPACE, ARROW_UP, ARROW_DOWN)
  • Imported COMMAND_PRIORITY_CRITICAL from Lexical
  • Updated comments to reflect the new priority level

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@zoltanhosszu
Copy link
Contributor

I like this, a simple solution, thank you @yanfroes!

@samuelpecher any feedback on this?

Copy link
Collaborator

@samuelpecher samuelpecher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; I wouldn't want to push the table handle commands down the priority list, so 👍

Copy link
Collaborator

@samuelpecher samuelpecher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could do with a test to ensure we don't regress in the future if priorities are ever revised.

Adds regression test for basecamp#677 to ensure arrow keys navigate prompt items when the prompt is opened inside a table cell. Verifies that prompt key handlers maintain COMMAND_PRIORITY_CRITICAL to prevent the table plugin from intercepting arrow key events.
@yanfroes yanfroes requested a review from samuelpecher February 9, 2026 22:06
@yanfroes
Copy link
Author

yanfroes commented Feb 9, 2026

@zoltanhosszu @samuelpecher Just added the test! =)

Copy link
Contributor

@zoltanhosszu zoltanhosszu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking solid! Let's ship it :) 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prompts keyboard controls are broken in tables

3 participants

Comments