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

fix: only clear timeout if the ongoingSelection is not empty #274

Conversation

mateuszmrw
Copy link
Contributor

@mateuszmrw mateuszmrw commented May 19, 2024

Closes: #262

Sorry for another one line PR.

It seems that for Apple Pencil touch events the updateSelectionTouchEvent function is called right away after the startSelectionTouchEvent, meaning that the function inside the touchTimer setTimeout never executes due to clearTimeout.
This leaves the ongoingSelection array empty meaning that the updateSelection is never called due to this if:

   if (wordIndex !== null && this.ongoingSelection.length) {
      this.updateSelection(wordIndex);
   }

This PR fixes it by only calling the clearTimeout if the this.touchTimer exists and the ongoingSelection is not empty

@simjanos-dev
Copy link
Owner

Sorry for another one line PR.

I always appreciate PR-s and bug reports to improve linguacafe.

The changes in the PR remove intended functionality: there should be half a second wait time after touching before the user can select multiple words.

I did this because on multiple phones there is a vibration when you keep touching something and don't move your finger. And recently, I thought about adding a hover vocabulary box functionality for tapping a word quickly on touch devices.

Based on your description, does this commit fix the problem for you with apple pencils? Now if the updateSelectionTouchEvent gets called during the 0.5s wait on the same word as the one you started the selection with, nothing will happen. It will only get canceled if you move the pencil enough start scrolling, or you move the pencil outside of the word.

(This is part 2 of a previous commit.)

@simjanos-dev
Copy link
Owner

It was confirmed on discord that it is working.

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.

Phrase selection does not work with apple pencil.
2 participants