question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

app hang while showing alert when select dropdown box is actively showing

See original GitHub issue

Bug Report

app hang while showing alert when select dropdown box is actively showing

Problem

cordova app went hang when calling javascript executing alert() when user has clicked the select box and the select box dropdown box is showing on screen

What is expected to happen?

alert box should show on top of the page, the app shouldn’t hang

What does actually happen?

Information

Please refer to the code below, there are one select box and one button, first, please click the button, the alert box will show after 2 seconds. After the button is clicked, do click the “select” box immediately, after that, wait for 2 seconds. Dismiss the dropdown box, the app will go hang and nothing is responding anymore.

Command or Code

Code snippet:

<!DOCTYPE html>

<html>
    <head>
        <meta charset="utf-8">
        <meta name="format-detection" content="telephone=no">
        <meta name="msapplication-tap-highlight" content="no">
        <meta name="viewport" content="initial-scale=1, width=device-width, viewport-fit=cover">
        <meta name="color-scheme" content="light dark">
        <link rel="stylesheet" href="css/index.css">
        <title>Hello World</title>
        <script>
            function test() {
                setTimeout(function(){ alert("Hello"); }, 2000);
            }
        </script>
    </head>
    <body>
        <div class="app">
            <h1>Apache Cordova</h1>
            <div id="deviceready" class="blink">
                <p class="event listening">Connecting to Device</p>
                <p class="event received">Device is Ready</p>
            </div>
            <select><option>sdfsdf</option>
                <option>sdfsdf</option>
                <option>sdfsdf</option>
            </select>
            <button type="button" onclick="test()">Click Me!</button>
        </div>
        <script src="cordova.js"></script>
        <script src="js/index.js"></script>
    </body>
</html>

Environment, Platform, Device

iOS device (iphone or ipad), tested in iOS 13 and 14

Version information

What are relevant versions you are using? For example: Cordova CLI 10.0.0 Cordova iOS: 6.1.0

Checklist

  • [x ] I searched for existing GitHub issues
  • [ x] I updated all Cordova tooling to most recent version
  • [x ] I included all the necessary information above

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
breautekcommented, Dec 29, 2020

What my guess is, Cordova using WebView implementation and also implement its own alert modal, which is not the same as the native browser.

Yah, you might be right here. I’m not too familiar with objective-c or the ios code base for that matter but Cordova has a `CDVWebViewUIDelegate class that looks like it handles how to display the alert box among other native modals like confirm and prompt.

https://github.com/apache/cordova-ios/blob/7e3402c565c2e34eae2bb954c65c989f71e20df1/CordovaLib/Classes/Private/Plugins/CDVWebViewEngine/CDVWebViewUIDelegate.m#L35-L55

This is where my expertise kinda ends. I’m not sure if there is a way to ensure that the alert modal is always displayed on top or if there is any other potential solutions but I think this method is the method of interest.

1reaction
samyc1201commented, Dec 29, 2020

it isn’t visible because it’s displayed under the select modal?

Yes it is not visible but it doesn’t show under select modal too. It is just not showing and the whole page is not responding, any click to the button or input element are not receivable.

Since you’re dealing with native browser UI, this smells like a browser bug.

I have tried just now, it doesn’t happen in Safari in my ipad.

What my guess is, Cordova using WebView implementation and also implement its own alert modal, which is not the same as the native browser. The alert modal (guess it is UIAlertController) doesn’t work well while there is select modal (not sure this, might be other UIViewController) showing.

I will try to look into “dialogs plugin”, although that is not convenient, because the usage of “alert()” is everywhere in my project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Excel Data Validation Tips and Troubleshooting - Contextures
Select the cell that contains a data validation list; Choose Data|Validation; On the Error Alert tab, add a check mark to the Show...
Read more >
Notifications Overview | Android Developers
Apps with active notifications display a notification "badge" on top of their app icon on the home/launcher screen. Users can now snooze a...
Read more >
How to set the 'selected option' of a select dropdown list with ...
Try this : $('select[name^="salesrep"] option[value="Bruce Jones"]').attr("selected","selected");. Just replace option[value="Bruce Jones"] by ...
Read more >
See and respond to notifications on Apple Watch
Apps can send notifications to keep you informed—meeting invitations, ... How the notification looks depends on whether the display is active or idle....
Read more >
JavaScript - Bootstrap
Multiple open modals not supported. Be sure not to open a modal while another is still visible. Showing more than one modal at...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found