syncfusion / flutter-widgets

Syncfusion Flutter widgets libraries include high quality UI widgets and file-format packages to help you create rich, high-quality applications for iOS, Android, and web from a single code base.
1.44k stars 672 forks source link

PDFViewer: onTap not working when flutter semantics enabled #1843

Open ledjoncili opened 2 weeks ago

ledjoncili commented 2 weeks ago

Bug description

SfPdfVieweronTap callback is not working on pdfs that have more than one page with FlutterSemantics enabled.

Steps to reproduce

  1. Load a pdf which has more than page
  2. Try to listen onTap event
  3. No feedback is given

Code sample

Code sample ```dart import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart'; void main() { WidgetsFlutterBinding.ensureInitialized(); SemanticsBinding.instance.ensureSemantics(); runApp(const MaterialApp( title: 'Syncfusion PDF Viewer Demo', home: HomePage(), )); } /// Represents Homepage for Navigation class HomePage extends StatefulWidget { const HomePage({super.key}); @override _HomePage createState() => _HomePage(); } class _HomePage extends State { final GlobalKey _pdfViewerKey = GlobalKey(); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Syncfusion Flutter PDF Viewer'), actions: [ IconButton( icon: const Icon( Icons.bookmark, color: Colors.white, semanticLabel: 'Bookmark', ), onPressed: () { _pdfViewerKey.currentState?.openBookmarkView(); }, ), ], ), body: SfPdfViewer.network( 'https://cdn.syncfusion.com/content/PDFViewer/flutter-succinctly.pdf', key: _pdfViewerKey, onTap: (val) { print('tapped'); }, ), ); } } ```

On which target platforms have you observed this bug?

Web

Flutter Doctor output

Doctor output ```console [✓] Flutter (Channel stable, 3.19.6, on macOS 14.4.1 23E224 darwin-arm64, locale en-DE) • Flutter version 3.19.6 on channel stable at /Users/cili/development/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 54e66469a9 (2 weeks ago), 2024-04-17 13:08:03 -0700 • Engine revision c4cd48e186 • Dart version 3.3.4 • DevTools version 2.31.1 [!] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at /Users/cili/Library/Android/sdk ✗ cmdline-tools component is missing Run `path/to/sdkmanager --install "cmdline-tools;latest"` See https://developer.android.com/studio/command-line for more details. ✗ Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/macos#android-setup for more details. [✓] Xcode - develop for iOS and macOS (Xcode 15.3) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15E204a • CocoaPods version 1.15.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2023.2) • Android Studio at /Users/cili/Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874) [✓] IntelliJ IDEA Community Edition (version 2023.3.4) • IntelliJ at /Users/cili/Applications/IntelliJ IDEA Community Edition.app • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart [✓] VS Code (version 1.88.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension can be installed from: 🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter [✓] Connected device (2 available) • macOS (desktop) • macos • darwin-arm64 • macOS 14.4.1 23E224 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 120.0.6099.234 [✓] Network resources • All expected network resources are available. ```
immankumarsync commented 2 weeks ago

Hi @ledjoncili, We are able to replicate the issue that the onTap callback is not working when adding the line SemanticsBinding.instance.ensureSemantics();. Currently, we are validating the root cause of this issue, and we will update further details here once the validation is completed.

immankumarsync commented 1 week ago

Hi @ledjoncili, By default, the onTap callback will not be invoked if the assistive technologies (like talkback and voiceover) are enabled. Please let us know the use case for the onTap callback with the assistive technologies.

ledjoncili commented 1 week ago

Hi @immankumarsync, No, I am not using any of them. As you can see in the code provided, no assistive technologies are used.

immankumarsync commented 4 days ago

Hi @ledjoncili, Could you please check the same case with Flutter SDK 3.22.0. It seems like the issue is fixed. Could you please confirm us whether the issue is resolved after Flutter SDK upgradation?

If the issue still occurs, try cleaning the project and run the project.