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

[lexical-table] Bug Fix: get table-cell background selection color from a class #6658

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

hamza221
Copy link

@hamza221 hamza221 commented Sep 22, 2024

Description

get table-cell background selection color from a class
I couldn't find where tableCellSelected is used, my guess is that it's not so I overwrote the class
and I don't think that tableCellSelectedOverwrite is a good name so I'm open for other suggestion it's there as a placeholder for now.
Closes #6655

Test plan

Copy link

vercel bot commented Sep 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 13, 2024 4:59am
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 13, 2024 4:59am

@facebook-github-bot
Copy link
Contributor

Hi @hamza221!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

Copy link

github-actions bot commented Sep 22, 2024

size-limit report 📦

Path Size
lexical - cjs 30.85 KB (0%)
lexical - esm 30.73 KB (0%)
@lexical/rich-text - cjs 39.58 KB (0%)
@lexical/rich-text - esm 32.67 KB (0%)
@lexical/plain-text - cjs 38.22 KB (0%)
@lexical/plain-text - esm 29.93 KB (0%)
@lexical/react - cjs 41.35 KB (0%)
@lexical/react - esm 34.03 KB (0%)

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 22, 2024
@hamza221
Copy link
Author

hamza221 commented Sep 24, 2024

  • I left the old logic in, because I'm not sure about another way to set a default value (new to the code base)
  • I'll update the failing tests once the logic gets approved

@ivailop7
Copy link
Collaborator

The CSS class is probably a leftover from the experimental table, which we deleted a year/year and a half ago. I think it's fine to reuse that CSS class, I did the same with reintroducing the hover add column/row buttons and reusing the existing CSS classes. I'm not in favour of adding an extra override CSS class, as long as you pick the CSS class name from the config.theme object use the existing CSS Class, also +1 for the test.

@etrepum
Copy link
Collaborator

etrepum commented Sep 24, 2024

I agree that an override class is not necessary. Should be up to the user to make sure their configuration of classes and styles composes correctly.

@matveeva-as
Copy link

Would be great to see this fix in the next release!

@ivailop7
Copy link
Collaborator

@hamza221 are you interested in finishing this one?

@hamza221
Copy link
Author

I'll send a commit tomorrow

@hamza221
Copy link
Author

🤞

Copy link
Collaborator

@etrepum etrepum left a comment

Choose a reason for hiding this comment

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

I think this is getting very close! I believe there's one mistake in the test changes, and that it can be simplified further by not using element.style at all

colspan="2"
style="background-color: rgb(172, 206, 247); caret-color: transparent">
class="PlaygroundEditorTheme__tableCell PlaygroundEditorTheme__tableCellHeader PlaygroundEditorTheme__tableCellSelected"
rowspan="2"
Copy link
Collaborator

Choose a reason for hiding this comment

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

This changing from colspan to rowspan seems suspicious?

Suggested change
rowspan="2"
colspan="2"

Copy link
Author

@hamza221 hamza221 Oct 22, 2024

Choose a reason for hiding this comment

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

it was an accidental ctrl c +ctrl v 😥 I'll revert it

@@ -1089,7 +1090,7 @@ export function $updateDOMForSelection(

if (selectedCellNodes.has(lexicalNode)) {
cell.highlighted = true;
$addHighlightToDOM(editor, cell);
$addHighlightToDOM(editor, cell, editor._config.theme);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this signature should change when the editor is an argument to this function already, would be easier to reference editor._config.theme from inside $addHighlightToDOM

Comment on lines +1308 to +1312
function $addHighlightToDOM(
editor: LexicalEditor,
cell: TableDOMCell,
editorThemeClasses: EditorThemeClasses,
): void {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
function $addHighlightToDOM(
editor: LexicalEditor,
cell: TableDOMCell,
editorThemeClasses: EditorThemeClasses,
): void {
function $addHighlightToDOM(editor: LexicalEditor, cell: TableDOMCell): void {
const editorThemeClasses = editor._config.theme;

Comment on lines +1323 to 1325
element.style.setProperty('background-color', `rgb(${BROWSER_BLUE_RGB})`);
}
element.style.setProperty('caret-color', 'transparent');
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think there's any reason to use style directly if we are applying classes correctly

@etrepum
Copy link
Collaborator

etrepum commented Nov 5, 2024

Were you planning to finish this PR?

@hamza221
Copy link
Author

! I believe there's one mistake in the test changes, and that it can be simplified further by not using element.style at all

I'm okay with someone else taking over, I'm Afk until 2025

@etrepum
Copy link
Collaborator

etrepum commented Nov 11, 2024

I'll take a look at finishing this after #6759

@hamza221
Copy link
Author

Thank you @etrepum

@etrepum etrepum self-assigned this Nov 11, 2024
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.

Feature: Support Custom Color for Table Selection Highlight
5 participants