-
Notifications
You must be signed in to change notification settings - Fork 204
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 mobile cursor from jumping to bottom #2625
Conversation
dc2fd09
to
3111f65
Compare
Codecov Report
@@ Coverage Diff @@
## master #2625 +/- ##
=======================================
Coverage 97.38% 97.38%
=======================================
Files 200 200
Lines 7466 7466
Branches 1647 1647
=======================================
Hits 7271 7271
Misses 195 195 Continue to review full report at Codecov.
|
The issue is not specific to Chrome-based browsers on Android, although it does cause much more of a problem in that browser than Safari on iOS.
This makes it easier to use the dev server for testing Hypothesis on mobile devices with smaller screens (ie. phones).
a69b397
to
796c74b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change here makes complete sense. user-select
is the right tool for this. I tested on iOS and it is possible to reproduce the problem but it is much less of an issue in practice due to slight differences in selection behavior in Safari vs. Chrome.
It looks like an earlier version of the change was committed directly to master by mistake in 3a28edd.
I have made a couple of further changes in this PR to reword the comment to clarify what user-select
does and remove the mention of Android, since the issue can occur in other browsers as well. I also made a change to use a mobile-optimized viewport for the dev server homepage for ease of testing.
The solution here resolves the immediate problem of text inside the adder being selected. However with I can see several ways we might be able to resolve this:
My recommendation would be to look into option (2) first of all. |
When selecting text on the android, it was possible to also highlight the text inside the buttons in the adder. When this happened, the range would grab everything from where you started to highlight to the very end of the dom because the adder is attached as the last node inside body.
The simple fix is to prohibit text selection inside the adder which prevents the selection from getting the adder itself.
This was a bit tricky to figure out.
1 You need an android
2 Set up remote debugging (see screen shot) https://developers.google.com/web/tools/chrome-devtools/remote-debugging
I tracked this down to an issue where in
selection.js
, it was grabbing a much larger range than it should have. I think what was happening it is the adder itself could act as part of the thing you can select/highlight. On mobile, events for selecting text, touching text, etc fire differently than on the desktop. If you moved you finger too fast or move over a transition from one common ancestor to another, then it grabbed the adder text too.I was able to totally prevent this by adding 'pointer-events: none; on the adder. While this fully disabled the adder, it fixed this issue. Next I thought that perhaps we should dynamically set that value and we should be good! I was able to pinpoint the problem by adding a simple condition inside
selectedRange
And then in guest.js, we can pass down a flag when range is null to add a css class to the adder. This actually didn't work very well perhaps due to something asynchronous that I didn't have a good understanding of.
The next idea was to just prevent css selection entirely and it didn't need a flag because I don't think we really care about allowing the text to be selected in the first place the adder.
Things to consider.
user-select
affects what a user can select. It doesn't affect how a screen reader reads controls - @robertknight)