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 bug with updating a deselected selection and void block selection issues #1075

Conversation

skogsmaskin
Copy link
Collaborator

@skogsmaskin skogsmaskin commented Sep 7, 2017

There are two things fixed here. The first one is a fix for content.updateSelection when the selection is deselected and anchorKey and focusKey is unset. It should then return as the rest of the code acts on anchorKey and focusKey.

The second fix is regarding selecting void nodes. When selecting text from a non-void block to the end, neighbouring a void-block, the focusOffset is (most of the time) set at the end of the void block when it shouldn't. This will delete the void block as well when you press backspace. Therefore make sure that the focusOffset is always set to 0 in the void block in those conditions.

Also if you move the cursor to a void-block, the same problem occur. It is most of the time set to anchor and focusOffset 1, making it impossible to delete it. In this case, set the anchorOffset to 0.

This was what I originally tried to fix in #1042
which was reverted via #1063 because of issues. It was probably the wrong place trying to fix it, but I hope this PR will make it proper and there are no side effects. Unfortunately it is a bit difficult to test because it relies on browser behaviour.

@skogsmaskin skogsmaskin force-pushed the fix-void-block-selection-issues branch from 516c926 to ccec890 Compare September 7, 2017 11:33
@skogsmaskin skogsmaskin force-pushed the fix-void-block-selection-issues branch from ccec890 to 25a2c04 Compare September 7, 2017 13:50
@ianstormtaylor ianstormtaylor merged commit 86c69f9 into ianstormtaylor:master Sep 7, 2017
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.

None yet

2 participants