Lovelace: Button card

Still a great card and I use it graciously, however the update to 2.x made the addon unusable for me. Every button I tap will inact a double tap. I know this is probably a bug in ios 13, but previously I could work around it by holding the button slightly longer than a tap but not too long to activate the hold_action. Unfortunately there is no way to do this anymore since this update and every button I press will turn itselfs back on/off immediately after pressing the button.

I will revert to 1.11 to see if it “fixes” my problem. I will also test this on my wifes phone later on as she is still on iOS 12. If Apple doesn’t fix this soon I am going crazy, and a gut feeling says they wont as it has been like this since beta 1 (we are on beta 4 now!)

Edit: it seems most prominent on buttons that switch conditional cards. Really strange

I guess if you use the default button from Home-Assistant Core, you have the same issue? (I use almost the same code as the one from Hass Core to handle tap and hold).
Would you mind doing the test please?
(the modification I did to handle tap and hold shouldn’t modify the behaviour… and also this shouldn’t be a problem as it works everywhere but not on IOS 13 :frowning: )

I’m downloading xcode beta to be able to run the simulator with IOS 13 and test what’s going on… I guess I’ll have to do a dirty hack for this to work again… argh I hate Apple IOS devices :slight_smile:

Srry not at home right now, but I have tested this with beta 1 and 2 and the behavior is the same with core buttons. So I don’t think there is really much you can do about it. I just noticed that with the 2.x update the behaviour is more prominent.

Pff I really hope that Apple will fix this, in the mean time I am going to try a fresh install of ios. Sometimes it helps doing this haha.

No need to reinstall. I’ve managed to reproduce using the IOS 13 simulator from xcode. I’ll try to learn how to debug this IOS sh*t :slight_smile:

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.