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

[SuperEditor][SuperReader][Android] Fix long-press firing after scrolling and releasing the pointer (Resolves #1535) #1540

Merged

Conversation

angelosilvestre
Copy link
Collaborator

@angelosilvestre angelosilvestre commented Oct 21, 2023

[SuperEditor][SuperReader][Android] Fix long-press firing after scrolling and releasing the pointer. Resolves #1535

When the editor or reader is inside a CustomScrollview, trying to drag is opening the software keyboard and changing the selection. This was partially solved in #1536. However one issue remained:

Starting a scroll gestures and the releasing the pointer is still causing the issue. The cause is that, when the timer fires, we aren't scrolling anymore.

To fix that, this PR cancels the long-press timer as soon as the user starts the scrolling gesture.

I kept the existing test, which simulates the user dragging and holding down the pointer, and added another one simulating the user starting a drag gesture and then releasing the pointer.

@angelosilvestre
Copy link
Collaborator Author

@Jethro87 could you please try this PR?

@@ -324,6 +324,12 @@ class _AndroidDocumentTouchInteractorState extends State<AndroidDocumentTouchInt

if (isScrolling) {
_isScrolling = true;

// The long-press timer is cancelled if a pan gesture is detected.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This explanation is too difficult to understand. It's not clear which part is describing what's happening now, or what isn't happening now, or what might be happening now. Please try to describe the relevant details in a way that a reader would understand by opening this file and looking directly at this explanation, like I'm doing now.

For example, reading this without all the pre-existing conversation and investigation, I don't know what it means to say "The long-press timer is cancelled if a pan gesture is detected". Does that mean we're cancelling it now? Does that mean it's already cancelled? Does that mean this if-statement "detected a pan gesture"? Does it mean that sometime earlier a pan gesture was detected? The explanation creates far more questions than it answers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I simplified the comment. Do you think it's clear enough?

@Jethro87
Copy link
Contributor

@angelosilvestre This looks good. I am not experiencing the issue on Android anymore.

@@ -304,6 +304,12 @@ class _ReadOnlyAndroidDocumentTouchInteractorState extends State<ReadOnlyAndroid

if (isScrolling) {
_isScrolling = true;

// The long-press timer is cancelled if a pan gesture is detected.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm gonna merge this because there's a critical long-press ticket from Superlist, but this comment is still ordered in a way that makes it unnecessarily difficult to understand what it's trying to say.

Generally, the first thing you should say in a comment is what the code is actually doing. Beginning with contextual qualifiers is confusing because you haven't event established what you're qualifying yet.

Here's a comment in reversed order:

// Cancel the long-press timer because we're scrolling, and scrolling is mutually
// independent from long-pressing.
//
// We also cancel the timer when a pan gesture starts. However, we won't receive
// a pan gesture event if we have an ancestor scrollable. Therefore, we cancel the
// timer here, too.

Copy link
Contributor

@matthew-carroll matthew-carroll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@matthew-carroll matthew-carroll merged commit 813f404 into superlistapp:main Oct 24, 2023
10 of 11 checks passed
matthew-carroll pushed a commit that referenced this pull request Oct 24, 2023
@matthew-carroll
Copy link
Contributor

I cherry-picked this to unblock some other work: #1553

matthew-carroll pushed a commit that referenced this pull request Oct 24, 2023
@angelosilvestre angelosilvestre deleted the 1535_release_pointer branch October 24, 2023 22:13
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.

[SuperEditor] Scrolling on Android in a CustomScrollView creates selection when it shouldn't
3 participants