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

Fix caret moving to end of placeholder on whitespace input #2865

Open
wants to merge 9 commits into
base: next
Choose a base branch
from

Conversation

idebenone
Copy link
Member

@idebenone idebenone commented Nov 9, 2024

Problem

Improper handling of visible whitespaces causing unwanted behaviour such as:

  • unable to delete trailing whitespaces in empty blocks.
  • caret jumping to the end of placeholder in paragraph block.

Solution

Update the isNodeEmpty() to handle visible whitespaces by removing the method call trim() in nodeText.trim().length as it would remove the trailing whitespaces if any exist which in turn falsely marks a block as empty. And because of this the whitespaces are unable to be removed.

@idebenone idebenone force-pushed the fix/whitespace-input-placeholder branch from 363612c to af3540a Compare November 9, 2024 10:46
src/components/dom.ts Outdated Show resolved Hide resolved
@idebenone idebenone force-pushed the fix/whitespace-input-placeholder branch from c2ab46f to fb311d0 Compare November 18, 2024 19:08
example/tools/code Outdated Show resolved Hide resolved
@idebenone idebenone force-pushed the fix/whitespace-input-placeholder branch from 096dd66 to b9e8404 Compare November 19, 2024 19:41
Copy link
Member

@neSpecc neSpecc 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, we should add tests for these 2 cases

  • backspace should remove trailing whitespaces in empty blocks
  • whitespaces in empty block should hide the placeholder

@idebenone idebenone force-pushed the fix/whitespace-input-placeholder branch from cb7a9e4 to 057914c Compare November 25, 2024 17:50
Copy link
Member

@neSpecc neSpecc left a comment

Choose a reason for hiding this comment

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

Be aware, don't delete submodules from the repo

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.

3 participants