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

onTapUrl does not fire when onTapImage is implemented and the element is an image that links somewhere #1050

Open
pellmr opened this issue Oct 12, 2023 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@pellmr
Copy link

pellmr commented Oct 12, 2023

Steps to Reproduce

given an image wrapped in an anchor tag
The onTapUrl handler never fires when onTapImage is implemented

HTML
<!DOCTYPE html>
<html>
<body>
<a href="/episodes"><img src="http://placekitten.com/200/300"></a>
</body>
</html>
`HtmlWidget` configuration
  HtmlWidget(
    html,
  onTapUrl: (String? url) async {
    if (url != null) {
      router().navigateTo(url);
    }
    return true;
  },
  onTapImage: (p0) {
    var image = p0.sources.first;
    showDialog(
        context: AioRouter().pageNavigatorKey.currentContext!,
        builder: ((context) => ImageViewer(
              imageUrl: image.url,
              height: image.height,
              width: image.width,
            )));
  },
  );
Tesing environment
Flutter (Channel stable, 3.13.6, on macOS 13.3.1 22E772610a darwin-x64, locale en-US)
    • Flutter version 3.13.6 on channel stable at /Users/pellmr/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ead455963c (2 weeks ago), 2023-09-26 18:28:17 -0700
    • Engine revision a794cf2681
    • Dart version 3.1.3
    • DevTools version 2.25.0

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/pellmr/Library/Android/sdk
    • Platform android-33, build-tools 31.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E300c
    • CocoaPods version 1.13.0

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.2)
    • Android Studio at /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.6+0-17.0.6b802.4-9586694)

[✓] VS Code (version 1.82.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.74.0

[✓] Connected device (2 available)            
    • macOS (desktop) • macos  • darwin-x64     • macOS 13.3.1 22E772610a darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 118.0.5993.70

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Expected results

I expected the onTapUrl handler to fire. Ideally I only want the image handler to fire if there is no anchor tag around it.

Actual results

only the onTapImage handler is fired, not the onTapUrl

@pellmr pellmr added the bug Something isn't working label Oct 12, 2023
@daohoangson daohoangson self-assigned this Oct 16, 2023
@daohoangson
Copy link
Owner

This is the intended behavior. Once an onTapImage callback is set, it will capture the tap event and won't allow onTapUrl to run. In order to improve this, we probably have to change the onTapImage to return a boolean to decide whether to continue calling onTapUrl.

@daohoangson daohoangson added enhancement New feature or request and removed bug Something isn't working labels Oct 18, 2023
@pellmr
Copy link
Author

pellmr commented Oct 18, 2023

One of the things I was trying to achieve was to link when there was a link, and display the image when there wasn't. Perhaps if there's a parent a element it could be included in the ImageMetadata so you can make decisions in the onTapImage callback with it. You could add the boolean to decide to call onTapUrl in addition to that.

@daohoangson
Copy link
Owner

That's definitely a valid use case. I guess we can pass the BuildTree to onTapImage to handle that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants