-
Notifications
You must be signed in to change notification settings - Fork 25
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: Whitespace added at the start on focus #43
Conversation
Maybe the non-breaking space is there from the beginning and just not displayed by the browser. I observed that in Chrome when logging a pasted value to the console. |
Right now the cleaning of internals remove spaces at the beginning but not at the end of a block. If you press enter at the end of a paragraph there is the chance of non breaking spaces on the block that is getting created afterwards. The cursor, however, is moved at the beginning of the block so you don't notice the space unless you press the right arrow key. We could improve the cleaning function and prevent this. |
I can reproduce it now in chrome. If you paste something like ' word' with a space at the beginning into an empty paragraph the space is not shown. After a Maybe we could prevent this in 'paste' and 'split' events instead of the cleanup method. |
Previously normalizeSpace assumed a parent node as argument. Now it works also when you pass a text node (this is the case of the paste).
@peyerluk I fixed the bug by running |
Lets try it just on focus and not on split. Then we just need to remember to always apply focus on the last possible moment. But I guess this is a good general rule anyway. |
In addition, when overriding some specific behaviors (as an implementor) I could be sure that on focus everything gets fixed and in general you are not likely to override the focus. My commit solves the bug so whenever you want feel free to merge. |
Don't you want to add it on |
It was already there, that is why the space was getting visible after blur/focus |
Hmm, then we need to do it on editable.add() as well... Or we need to remove/collapse all whitespaces except non-breaking spaces on editable.add(). |
I would add it the "add" function as you mentioned. |
This doesn't remove spaces at the end, it just converts the last one to make it visible. I think the strategy of not having spaces at all in the end should go in a config option and shouldn't be a task of normalizeSpaces.
👍 |
Bug: Whitespace added at the start on focus
Sometimes a non-breaking space is added to the beginning of a block. I cannot reproduce it reliably, but it happens quite often.