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

Increased the collapsed check timeout on pointerup #162

Conversation

oleksandr-danylchenko
Copy link
Contributor

@oleksandr-danylchenko oleksandr-danylchenko commented Oct 15, 2024

Issue

Source - #136 (comment)

Unfortunately, I noticed that the "lagging behind isCollapsed property" is still a thing for touch devices! When I tap somewhere around the selection - the isCollapsed is still true when the onPointerUp gets handled, even within the setTimeout.
image
That creates a weird effect that makes a user tap twice to dismiss the selection. Similar to the one we had in the demos above ;(

Changes Made

Source - #136 (comment)

Incredibly... increasing the setTimeout's timeout from the default 0 to 1 helps! It starts reporting the isCollapsed properly again!
image

UPD: Turned out that 1ms. isn't always enough, so I switched to the 5ms. delay instead

@oleksandr-danylchenko oleksandr-danylchenko marked this pull request as draft October 15, 2024 14:04
@oleksandr-danylchenko
Copy link
Contributor Author

I think that approach should be more flexible here...
I discovered that on iOS it takes up to 40ms to properly report that the selection range is collapsed even when a user clicks beyond the existing selection! But if we decide to apply such a timeout universally - it'll make user experience on desktops and Androids slower in general.
Instead, we may wanna have a "polling" for the range collapse state 🤔. If the timeDifference is smaller than the CLICK_TIMEOUT and the range isn't collapsed - we start polling it for up to 50ms. (to be extra cautious). So if the browser changes its state quicker - it won't be held off by a "blind" timeout.

@oleksandr-danylchenko oleksandr-danylchenko deleted the fix-obsolete-collapsed-state branch October 15, 2024 14:55
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.

1 participant