Repository navigation
Update the documentation of Semantics' onLongPress #35112
Copy link
Copy link
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)Accessibility, e.g. VoiceOver or TalkBack. (aka a11y)found in release: 1.21Found to occur in 1.21Found to occur in 1.21found in release: 2.9Found to occur in 2.9Found to occur in 2.9frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work on
Description
Steps to Reproduce
A working repro is located at https://github.com/kpsroka/flutter_accessibility_demo/tree/onLongPress-Bug (notice the tag)
The core part of the problem is the following:
Semantics(
label: 'Counter button',
hint: 'Press to increase',
value: '$_counter',
enabled: true,
container: true,
excludeSemantics: true,
onTap: _incrementCounter,
onLongPress: _decrementCounter,
child: Text(
'$_counter',
style: Theme.of(context).textTheme.display1,
)),
- Launch on an iOS device with VoiceOver enabled, or on an Android device with TalkBack enabled.
- Launch the project mentioned above.
- Move focus to the counter number. Double-tap to trigger the "tap" handler, double-tap & hold to trigger the "long press" handler.
Observed:
onTaphandler is being executed, whileonLongPresshandler isn't.
However, when you enable semantics debugger (uncomment this line), you'll be able to trigger the onLongPress handler.
Logs
flutter run --verbose without SemanticsDebugger
flutter run --verbose with SemanticsDebugger
Notice that I removed the debugPrint statements from the code before executing the above commands.
$ flutter doctor -v
[✓] Flutter (Channel beta, v1.6.3, on Mac OS X 10.14.5 18F132, locale en-PL)
• Flutter version 1.6.3 at /Users/krzysztofsroka/Library/Flutter
• Framework revision bc7bc94083 (5 weeks ago), 2019-05-23 10:29:07 -0700
• Engine revision 8dc3a4cde2
• Dart version 2.3.2 (build 2.3.2-dev.0.0 e3edfd36b2)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /Users/krzysztofsroka/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• ANDROID_HOME = /Users/krzysztofsroka/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
• All Android licenses accepted.
[✓] iOS toolchain - develop for iOS devices (Xcode 10.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.2.1, Build version 10E1001
• ios-deploy 1.9.4
• CocoaPods version 1.6.1
[!] Android Studio (version 3.2)
• Android Studio at /Applications/Android Studio.app/Contents
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
[✓] VS Code (version 1.35.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.1.0
[✓] Connected device (1 available)
• CK test • 7fd603d4b73339426ca23d745840a51dfcfbaecc • ios • iOS 12.2
! Doctor found issues in 1 category.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)Accessibility, e.g. VoiceOver or TalkBack. (aka a11y)found in release: 1.21Found to occur in 1.21Found to occur in 1.21found in release: 2.9Found to occur in 2.9Found to occur in 2.9frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work on
Activity
[-]Semantics' onLongPress doesn't get triggered without showSemanticsDebugger[/-][+]Semantics' onLongPress doesn't get triggered without setting MaterialApp.showSemanticsDebugger[/+]markusaksli-nc commentedon Aug 5, 2020
Reproducible on the latest master
1.21.0-6.0.pre.191.Minimal reproducible code sample
flutter doctor -v
AlexV525 commentedon Jan 22, 2022
Reproducible on the latest master 2.9.0-1.0.pre.452.
showSemanticsDebuggerfalseRecord_2022-01-22-16-19-05_addc32bca73e9f6027afbb.mp4
showSemanticsDebuggertrueRecord_2022-01-22-16-20-23_addc32bca73e9f6027afbb.mp4
flutter doctor -v
AlexV525 commentedon Jan 22, 2022
/cc @chunhtai
AlexV525 commentedon Jan 22, 2022
Workaround for TalkBack:
chunhtai commentedon Jan 24, 2022
voiceover sends the long press directly to the application instead of semantics action. you need to use gesture recognizer in this case.
chunhtai commentedon Jan 24, 2022
closing this issue
AlexV525 commentedon Jan 25, 2022
@chunhtai This also happened to Talkback, see screen records above. Now they behave the same. I don't think there is a platform regression, but the framework might do.
kpsroka commentedon Jan 25, 2022
@chunhtai The documentation for SemanticsProperties.onLongPress [permalink] says:
So I believe that this is intended to to work on both VoiceOver and TalkBack, and if it's not the intention, then it should not have such documentation.
AlexV525 commentedon Jan 25, 2022
/cc @goderbauer who originally wrote the doc. [blame ref]
chunhtai commentedon Jan 25, 2022
We can't control how the platform decide to interpret the accessibility long press, it looks like in some case they are sent through semantics action and sometimes it synthesizes a screen long press. We need to update the documentation.
[-]Semantics' onLongPress doesn't get triggered without setting MaterialApp.showSemanticsDebugger[/-][+]Update the documentation of Semantics' onLongPress[/+]Clarifies semantics long press and semantics on tap documentation (#1…
github-actions commentedon Jun 23, 2023
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.