lexical
lexical copied to clipboard
Bug: Not able to set the text color upon closing color pallet
The user can't set the text color if the color pallet is closed. On the other hand, it works fine if the pallet is not closed.
Lexical version: latest
Steps To Reproduce
- Go to the lexical playground and type a few characters
- Now select the text color from the top toolbar.
- Click inside the editor to close the pallet and type text further.
- Now you will see the text color is not applied.
Link to code example: https://playground.lexical.dev/
The current behavior is text color is not applied.
The expected behavior should be text color applied.
It happens because selection is updated by clicking the text with black color when closing the dropdown:
- when we select the new font color (red) on the color picker,
selectionupdates to have style of red color properly - right after that, we click the last text to continue writing with red color and close the dropdown
- BUT clicking the last text updates the selection with the style of clicked text.
- when that style is different from what we expected by selecting from the picker, It appears like a bug in the end.
https://github.com/user-attachments/assets/fae9abc2-afef-48fe-876f-feb1a43d2e28
So this can happen on other case as well such as font size. But in this case, it doesn't feel like a bug (at least for me). IMO, it is because there is no dropdown. So it is natural to continue writing without selecting the last text.
https://github.com/user-attachments/assets/e9140f2a-be89-4088-87de-16b0c381c681
So closing dropdown by click preserving the selection could be a fix.