Lovelace: Button card

Yeah I have the same issue on iOS 13. I wonder if the issue also happens in Safari desktop in Catalina? I can’t update my work laptop to test.

@jimz011, so I’ve checked… IOS 13 safari sends 4 javascript events when you tap a button:

  • touchstart
  • touchend
    delay like 100 or 200ms (WTF?)
  • mousedown (NEW, this creates a second click… that’s why it’s disabled again directly!)
  • click

While IOS 12 only sends 3 events when you tap a button:

  • touchstart
  • touchend
  • click

I’ll have a more in deep check of what is happening… I guess we’ll have to add some cooldown time to avoid running events multiple time…
Also it happens also for the Core Home Assistant button…

I hate you Apple !! :face_with_symbols_over_mouth::face_with_symbols_over_mouth::face_with_symbols_over_mouth:


EDIT: Found an super ultra ugly way to handle Apple’s crazy behavior…
@iantrich, that’s something you’ll love :smiley:

    const br = Bowser.getParser(window.navigator.userAgent);
    const isCrazyBrowser = br.satisfies({
      mobile: {
        safari: '>=13',
      },
    });
    element.addEventListener('touchstart', clickStart, { passive: true });
    element.addEventListener('touchend', clickEnd);
    element.addEventListener('touchcancel', clickEnd);
    if (!isCrazyBrowser) {
      element.addEventListener('mousedown', clickStart, { passive: true });
      element.addEventListener('click', clickEnd);
    }

That works !!! :tada:

Yes it also happens for the core button. I think I have created an issue for this on the Home Assistant github page (but honestly I can’t remember as I think I did this with the first beta).

Apple is changing a lot with iOS 13 (the Apple TV will no longer work with HA with TVOS 13). Really annoying, and they operate really weird, on one side they are opening up ios more and more for developers and at the same time they are locking already open features. Really annoying!

However it is still in beta, so it might change (but like I said it is beta 4 already and less than 2 months from release) usually these kind of things are fixed pretty quick.

Please read the 2.0.0 changelog first, if you didn’t do it.

:tada::tada: Version 2.0.4 :tada::tada:
BUGFIXES

  • Fix when a “templatable” field had the null value (@iantrich)
  • IOS 13 beta’s strange tap behaviour should be fixed now! Also on the IOS Beta Home Assistant App. (let me know if that works now @jimz011 @shauder)
3 Likes

Oh man, custom_fields makes this endless…

3 Likes

It looks like it fixed it for me inside of Safari but I still have the same issue using the iOS companion app. Perhaps the user agent is different when loading from inside the iOS app?

Okay, I’ll check that part, probably the user agent yes…

Indeed it still does it on the ios app (haven’t tried safari yet, will do this right now :stuck_out_tongue:)

@robbiet480, could you please help me and tell me the user-agent string you’re using on your beta IOS app? :pray:

[29/Jul/2019:12:50:32 -0500] "GET /community_plugin/button-card/button-card.js HTTP/2.0" 304 0 "https:///lovelace/main" "Mozilla/5.0 (iPhone; CPU iPhone OS 13_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148" "-"

This is from my NGINX logs.

Thanks!
:face_with_symbols_over_mouth: It doesn’t include Safari 13… :face_with_symbols_over_mouth: I’ll have to use iPhone OS 13_0 as the string I guess…

Maybe he can adjust the app to properly represent that it is safari. Since it technically is?

I’ve just published 2.0.4 which now hopefully also fixes this issue.

I have just tested and it works! Thanks!

1 Like

All of this nonsense doesn’t help me to hate less IOS :smiley:

2 Likes

I havent updated this yet, because I am installing beta 5 right now. It might have fixed the problem all together but who knows. I will let you know after I have completed installing it. The reason I wait is because I want to see if anything has changed on Apple’s side.

I’ve opened a thread on Apple’s dev forum… I don’t know if that’s the right place to report for such things…
https://forums.developer.apple.com/message/374096

Please let me know if beta 5 fixes it with a version of button-card which is <=2.0.2

Haha I have to say that was a strange change. I do have another issue but not sure if it’s the button card. When I press a button quickly sometimes it will trigger another button that appears in the same spot. It’s like there is a second press happening. Here is a gif that shows it activating the weather pop up after pressing the back button.

That is disgusting…

Edit: With this hack, does it make it so mouse support on iOS 13 doesn’t work? I would think so. :man_shrugging:

Sounds like you are running ios 13 :stuck_out_tongue:

Edit: but no I have this too, but I think it is related to ios 13. If it isn’t I’d be happy to know.