Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Table Selection is displayed when editor does not have focus #7083

Open
RyoSogawa opened this issue Jan 23, 2025 · 1 comment
Open

Bug: Table Selection is displayed when editor does not have focus #7083

RyoSogawa opened this issue Jan 23, 2025 · 1 comment
Labels
selection tables Relates to Lexical Tables

Comments

@RyoSogawa
Copy link

Lexical version: Latest(Playground)

Steps To Reproduce

  1. Insert a TableNode
  2. Select all in the editor using Cmd+A
  3. Press the Esc key
2025-01-23.13.49.48.mov

Link to code example

  • Playground

The current behavior

  • The selection state of the table remains active.

The expected behavior

  • The table selection state should be cleared and no color should be applied.

Impact of fix

  • I don't think it has a major impact.
@etrepum etrepum added tables Relates to Lexical Tables selection labels Jan 31, 2025
@etrepum
Copy link
Collaborator

etrepum commented Feb 9, 2025

So in this case what's happening is that the selection still includes the table, but the table selection styles are displayed whether the editor has focus or not. This can be worked around with CSS

diff --git a/packages/lexical-playground/src/themes/PlaygroundEditorTheme.css b/packages/lexical-playground/src/themes/PlaygroundEditorTheme.css
index 02197f4cc..328904110 100644
--- a/packages/lexical-playground/src/themes/PlaygroundEditorTheme.css
+++ b/packages/lexical-playground/src/themes/PlaygroundEditorTheme.css
@@ -220,7 +220,7 @@
 .PlaygroundEditorTheme__tableSelection *::selection {
   background-color: transparent;
 }
-.PlaygroundEditorTheme__tableSelected {
+[contenteditable]:focus-within .PlaygroundEditorTheme__tableSelected {
   outline: 2px solid rgb(60, 132, 244);
 }
 .PlaygroundEditorTheme__tableCell {
@@ -256,7 +256,7 @@
 .PlaygroundEditorTheme__tableCellSelected {
   caret-color: transparent;
 }
-.PlaygroundEditorTheme__tableCellSelected::after {
+[contenteditable]:focus-within .PlaygroundEditorTheme__tableCellSelected::after {
   position: absolute;
   left: 0;
   right: 0;

@etrepum etrepum changed the title Bug: Table Selection State Persists After Cmd+A and Esc Bug: Table Selection is displayed when editor does not have focus Feb 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
selection tables Relates to Lexical Tables
Projects
None yet
Development

No branches or pull requests

2 participants