custom-ui icon indicating copy to clipboard operation
custom-ui copied to clipboard

swipe-card: Prevent touchend from reaching cards

Open postlund opened this issue 6 years ago • 4 comments

The main purpose of this PR is to "fix" the unwanted clicking of cards during swiping on mobile devices, that has been pointed out quite a few times in https://community.home-assistant.io/t/lovelace-swiper-card/72447. It does so by turning the event propagation order around for touchend (used to identify clicks in most cases) from bubbling to capture. This way the event can be stopped from reaching the cards in case swiping was performed. Before, the touchend would start at the cards and propagate back to this component, so the click action would always be performed.

This is probably not the best way of doing things (I am by no means a web developer) and it is not very well tested (my only use case is with some button cards). So I'm throwing this out there to get some feedback, would be very nice to see this issue fixed.

postlund avatar Jun 12 '19 04:06 postlund

Thanks for the PR, I have to dive into this, and don't have the time at the moment. Will get back asap!

bramkragten avatar Jun 20 '19 07:06 bramkragten

No worries! One thing that you could argue is missing is a check it touch is supported. In the end it doesn't matter, but it would be nice.

postlund avatar Jun 22 '19 10:06 postlund

OK, sorry for the wait. Will look into this this week. Have you experienced any problems or all good?

bramkragten avatar Aug 07 '19 20:08 bramkragten

No worries! I've been using it a lot on my phone and it works very good in my particular use cases. You cannot, however, place other touch components (like an input_number In slider mode), in a card. That will just act weird.

postlund avatar Aug 08 '19 10:08 postlund