Skip to content

[lexical-playground] Bug Fix: Keep cell background color modal open on first click#8806

Merged
etrepum merged 1 commit into
facebook:mainfrom
sahiee-dev:fix/table-cell-color-modal-dismiss
Jul 8, 2026
Merged

[lexical-playground] Bug Fix: Keep cell background color modal open on first click#8806
etrepum merged 1 commit into
facebook:mainfrom
sahiee-dev:fix/table-cell-color-modal-dismiss

Conversation

@sahiee-dev

Copy link
Copy Markdown
Contributor

Description

Current behavior: In TableCellActionMenuContainer, the modal returned byuseModal() is rendered inside the tableCellNode != null conditional. On the first click anywhere inside the "Cell background color" modal (the panel chrome,hex input, swatches, saturation area, or hue slider), focus/selection leaves the editor, SELECTION_CHANGE_COMMAND fires and $moveMenu() runs.

Since the selection is no longer a range/table selection inside the editor root, disable() is called -> setTableMenuCellNode(null) -> the conditional unmounts {colorPickerModal} and the modal disappears on that first interaction. Clicking the cell again re-mounts it (the useModal state lives in the still-mounted container), which is why it "comes back" and then behaves normally.

Changes in this PR: Move {colorPickerModal} outside the tableCellNode != null conditional. The Modal is already a portal to document.body, so its JSX position has no layout effect, and it no longer unmounts when the selection leaves the editor. The modal now stays open on the first click and only closes via the close button, the overlay, or Escape.

Closes #8804

Test plan

Before

  1. Open the playground and insert a table (Insert -> Table)
  2. Click a cell -> click the cell action button (chevron) -> Background color
  3. Click anywhere inside the modal (e.g. the hex input or the color area)

The modal immediately disappears on that first click.

Screen.Recording.2026-07-07.at.5.05.28.PM.mov

After

Same steps: the modal stays open on the first click, the cell background updates
live as a color is picked, and the modal only closes via the close button, the
overlay, or Escape.

Screen.Recording.2026-07-07.at.5.06.24.PM.mov

…n first click (facebook#8804)

The cell 'Background color' modal is rendered inside the tableCellNode != null
branch of TableCellActionMenuContainer. Clicking anywhere inside the modal moves
the selection out of the editor, so $moveMenu() calls disable() and resets
tableCellNode to null, unmounting the modal on the first interaction.

Render {colorPickerModal} outside that conditional. The Modal is a portal to
document.body, so its JSX position has no layout effect, and it no longer
unmounts when the selection leaves the editor.

Closes facebook#8804
@vercel

vercel Bot commented Jul 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview Jul 7, 2026 11:41am
lexical-playground Ready Ready Preview Jul 7, 2026 11:41am

Request Review

@etrepum etrepum added this pull request to the merge queue Jul 8, 2026
Merged via the queue into facebook:main with commit b3d15d3 Jul 8, 2026
46 checks passed
@etrepum etrepum mentioned this pull request Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Table cell "Background color" picker modal disappears on first click inside the modal

2 participants