onTap does not recognize longer taps

Open
#8,326 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
typescript

Research direction

Start by locating the onTap event entry point and the touch-event handling used by NativeScript controls. Compare how release actions are handled for short and long presses, then check the relevant Android and iOS behavior against the requested accessibility outcome. Done means a longer press triggers onTap on release without breaking longPress behavior, with coverage for both platforms.

Written by the indexing model from the issue text.

Description

enhancement os: android

Is your feature request related to a problem? Please describe.

The onTap event is only triggered by short taps where the finger is released quickly. If you hold down the finger for too long, the onTap event gets cancelled. In terms of accessibility (weak fingers, loss of tactile sensitivity, bad eyesight) and external consistency (compare to standard tap events on Android and iOS built-in apps), this is undesirable. Imagine a user that has weakened fingers due to for example multiple sclerosis, who adopts a usage pattern where buttons are tapped for seconds at a time to ensure that the button was hit.
There is a longPress event but that does not trigger on release like onTap so it does not solve the problem.

Describe the solution you'd like

The onTap event should not be cancelled by default for longer presses.

Describe alternatives you've considered

A workaround for that worked for us is to use the touch event instead of onTap, and check if the action type was "up".
This is what it looks like in vue in the context of a RadListView:

<Ripple
        @touch="onItemSelected($event, index)"
        ...


private onItemSelected(event, index): void {
        if (event.action === "up") {
                //Do the thing
        }
}

Additional context

Relevant WCAG guideline: https://www.w3.org/TR/WCAG21/#pointer-cancellation

Dominant language
TypeScript
Stars
25.7k
Forks
1.7k
Avg merge
1d 5h
Merged PRs (30d)
35

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NativeScript/NativeScript

All issues in NativeScript/NativeScript

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.