Call setCursor onTouchEnd when moving between thoughts#4596
Draft
ethan-james wants to merge 4 commits into
Draft
Call setCursor onTouchEnd when moving between thoughts#4596ethan-james wants to merge 4 commits into
ethan-james wants to merge 4 commits into
Conversation
Contributor
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4173
Rapid taps between thoughts trigger the same type of focus-retargeting on iOS Safari that was implicated in #4291 and #4394. The mouse events arrive on the wrong element, so all of the cursor-management logic sets focus on the wrong element. The only events that arrive on the correct editable are touch events, so it is necessary to manage the cursor from there.
It is also necessary to detect and block mouse events that land on the wrong editable. This is accomplished by storing the last element to receive a touch event, and then calling
preventDefaultinonMouseDownin order to stop focus on the re-targeted editable.Lack of test coverage
Copilot was unable to reproduce the bug in BrowserStack. Efforts are documented in #4538. The taps were confirmed to be landing in the correct places, but latency between taps was pretty high, above 750ms. When I instrumented the iPhone and reproduced the bug manually, taps were closer to 250ms apart.
Copilot was able to get the taps closer together by combining them in a single
performActionscall, but it didn't help to reproduce the bug.Related note
It was necessary to avoid calling
selection.setinsideonTouchEnd, as that would swallow subsequent rapid taps entirely. This moves us a bit closer to the future imagined in #4470. It would, however, be nice if this logic would only be invoked for the second (buggy) tap rather than every tap that fits the profile of moving between thoughts with the keyboard open. I'm still mulling that last bit, as well as the new module-level variables that I don't love.