Skip to content
This repository has been archived by the owner on Mar 14, 2023. It is now read-only.

showDialog() while a WebViewX is on screen disables alert buttons #30

Closed
APDos opened this issue Aug 25, 2021 · 6 comments
Closed

showDialog() while a WebViewX is on screen disables alert buttons #30

APDos opened this issue Aug 25, 2021 · 6 comments

Comments

@APDos
Copy link

APDos commented Aug 25, 2021

I have an app that loads some HTML from assets on first launch as the body of a Scaffold, and while this HTML is being displayed, I found that when I call showDialog(), all of the buttons in the alert are not clickable, and I am still somehow able to interact with the HTML behind it.

Rough example:

Scaffold(
    body: WebViewX(
        onWebViewCreated: (controller) {
        webviewController = controller;
        webviewController.loadContent(
           'assets/welcome.html', SourceType.HTML,
            fromAssets: true);
           },
       )
)

The alert is standard

showDialog(
          context: context,
          builder: (context) {
            return WillPopScope(
              onWillPop: () async => barrierDismissable,
              child: AlertDialog(
                title: Text(title),
                content: content,
                actions: actions,
              ),
            );
          })```

Could this be my implementation or has someone seen something similar?
@APDos
Copy link
Author

APDos commented Aug 25, 2021

I found that adding

controller.setIgnoreAllGestures(true);

fixes the issue for the alert, however I need to be able to click buttons in the HTML

@APDos
Copy link
Author

APDos commented Aug 25, 2021

As a quick fix, I added a value to a ChangeNotifier I had already implemented to set the ignoreAllGestures value based on whether or not the alert was showing. It's a bit of a hack, but I'm short on time unfortunately. Still, this seems like an issue that could get others stuck in the future!

@adrianflutur
Copy link
Owner

Hi, yes this is a known issue, but the fix is already available in the package.

You can read about the WebViewAware widget in Readme.md, or check out the helpers.dart file from the example app:
https://github.com/adrianflutur/webviewx/blob/main/example/lib/helpers.dart

I guess I should add this to #27.

@APDos
Copy link
Author

APDos commented Aug 25, 2021

Thanks for the response! As someone who is using this for web specifically, I wouldn't have thought to check the "Diferences between Web and Mobile behaviour" for this fix, just as a thought. Thanks for having a fix for it though, it's much cleaner than mine. And this won't affect other places I'm using the alert where there is no WebView?

@adrianflutur
Copy link
Owner

WebViewAware only has effect on web, and only when there's other HtmlElementView (any HTML element, iframe in this case) behind it. It won't affect usage in other places. Also it does nothing on mobile.

@APDos
Copy link
Author

APDos commented Aug 25, 2021

Fantastic, thank you again!

@APDos APDos closed this as completed Aug 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants