No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    $q.appVisible is firing twice on clicking the tab

    Framework
    3
    9
    225
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      jitendra16 last edited by jitendra16

      This post is deleted!
      dobbel 1 Reply Last reply Reply Quote 0
      • dobbel
        dobbel @jitendra16 last edited by

        @jitendra16

        tried a lot of different browsers but I see no popup or and kind of UI interface except some text.

        J 1 Reply Last reply Reply Quote 0
        • J
          jitendra16 @dobbel last edited by jitendra16

          @dobbel after running codepen, switch to another tab to loose visibility, then come back to codepen tab. it will fire new tab opening on getting visibility, if not, then check the right most area of addressbar showing pop-up blocked sign.

          beets 1 Reply Last reply Reply Quote 0
          • beets
            beets @jitendra16 last edited by

            @jitendra16 I think this is a browser bug that window.open is toggling the app visibility. What exactly are you trying to accomplish? You may be able to achieve it with something like this:

            var new_window = window.open('some url')
            new_window.onbeforeunload = function(){ /* my code */ }
            

            https://stackoverflow.com/questions/9388380/capture-the-close-event-of-popup-window-in-javascript

            J 1 Reply Last reply Reply Quote 0
            • J
              jitendra16 @beets last edited by

              @beets No, its not because of browser bug as I tried to console log ‘Date.now()’ and found out that ‘$q.appVisible’ watch code is called twice.

              beets 1 Reply Last reply Reply Quote 0
              • beets
                beets @jitendra16 last edited by

                @jitendra16 I checked in your codepen, and I don’t get the same results without window.open. Keep in mind, the watch handler does fire twice, once when it becomes not visible, and once when it becomes visible again. So maybe if you had the console.log outside the if(state) condition is why you saw it fire twice.

                watch: {
                    '$q.appVisible' (state) {
                      if(state && this.counter < 9) {
                        console.log(Date.now())
                      }
                      this.counter++
                    }
                  }
                
                J 1 Reply Last reply Reply Quote 0
                • J
                  jitendra16 @beets last edited by

                  @beets Yes, you are right. Let me try your suggestion.

                  var new_window = window.open('some url')
                  new_window.onbeforeunload = function(){ /* my code */ }
                  
                  beets 1 Reply Last reply Reply Quote 0
                  • beets
                    beets @jitendra16 last edited by

                    @jitendra16 That code is just a starting point, btw. You may want to add more details on what you actually want to accomplish. See https://xyproblem.info/

                    I assume you want when a popup is closed to open another, but are these links on the same domain as yours? If so, onbeforeunload may not work, you’ll have to experiment a bit.

                    J 1 Reply Last reply Reply Quote 0
                    • J
                      jitendra16 @beets last edited by jitendra16

                      @beets Sure. Actually, i have a followup list of persons with their WhatsApp number, so I am triggering prefilled msgs to Whatsapp API. So the flow is like this.

                      1. user starts the sequence on btn click
                      2. App open WA API for 1st record.
                      3. user send the msg on whatsapp App
                      4. Comes back to our App
                      5. App open WA API for 2nd record
                        so on.
                      window.open(`https://wa.me/91${bulk[this.WAsequence].number}?text=${encodeURIComponent(bulk[this.WAsequence].message)}`
                      
                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post