Skip to content

Conversation

@atk
Copy link
Member

@atk atk commented Feb 14, 2025

If you triple click on an li inside a list inside a contenteditable div (except for the last one), you get a selectionEnd of NaN. This is because for reasons unknown, in this case we receive the parent of the text node instead of the text node in the range.

@changeset-bot
Copy link

changeset-bot bot commented Feb 14, 2025

🦋 Changeset detected

Latest commit: 4ddea69

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@solid-primitives/selection Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@atk atk force-pushed the fix-contenteditable-node-detection branch from e626353 to f3ed2d6 Compare February 14, 2025 16:27
@atk atk marked this pull request as ready for review February 14, 2025 16:27
@atk atk requested a review from thetarnav February 14, 2025 16:29
@thetarnav
Copy link
Member

thetarnav commented Feb 14, 2025

Why not change the logic only in the NaN case?

tbh they only think that is missing is some sort of acknowledgement of that edge-case in the code

@atk
Copy link
Member Author

atk commented Feb 14, 2025

This fix addresses the only cause for the NaN case that I could find, which seems to be inconsistent browser behavior. First checking for NaN and only then checking if the parent matches will only increase the code size.

@thetarnav thetarnav merged commit 8153bfa into main Feb 15, 2025
2 checks passed
@thetarnav thetarnav deleted the fix-contenteditable-node-detection branch February 16, 2025 10:39
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