Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control buttons don't reset to inactive style after click on touch devices #5284

Closed
digitaltom opened this issue Jan 2, 2025 · 12 comments · Fixed by #5285
Closed

Control buttons don't reset to inactive style after click on touch devices #5284

digitaltom opened this issue Jan 2, 2025 · 12 comments · Fixed by #5285
Labels
need more info Further information is requested

Comments

@digitaltom
Copy link
Contributor

digitaltom commented Jan 2, 2025

maplibre-gl-js version: 4.7.1 / 5.0

browser: Mobile Firefox, Mobile Chrome

Steps to Trigger Behavior

  1. Click on any control button (like zoom-in, zoom-out)
  2. See the clicked control button still being active (highlighted)
  3. Control button state only gets reset after click on the map

The issue only happens on mobile browsers / touch devices. On desktop, the control button style resets correctly after click.

Link to Demonstration

Demo: https://jsbin.com/bomimibija/edit?html,output

Expected Behavior

Control button highlight style should reset after click.

Actual Behavior

Control button highlight style stays active until click on map.
Video:

screen-20250102-133816.mp4
@digitaltom digitaltom changed the title Control buttons don't reset to inactive state after click on touch devices Control buttons don't reset to inactive style after click on touch devices Jan 2, 2025
@HarelM
Copy link
Collaborator

HarelM commented Jan 2, 2025

I tend to think this is related to the following issue:

I believe this is related to a11y (accessibility) definitions of Firefox and mobile chrome.

@HarelM HarelM added the need more info Further information is requested label Jan 2, 2025
@digitaltom
Copy link
Contributor Author

digitaltom commented Jan 2, 2025

Ok, I think I've found the issue:
The maplibre css defines a hover effect on the ctrl buttons, which is discouraged on mobile, because mobile browsers set the hover state on click, but only reset it when clicking on some other element, not when dragging the map for example.

CSS that causes this effect

.maplibregl-ctrl button:not(:disabled):hover {

.maplibregl-ctrl button:not(:disabled):hover{
            background-color:rgb(0 0 0/5%)

This jsbin shows the fixed behavior.
I can propose a patch for this issue later.

@HarelM
Copy link
Collaborator

HarelM commented Jan 2, 2025

Can you link to an article about the discouraging you referenced above?
Also, I think I still see the issue in the jsbin you linked...

@digitaltom
Copy link
Contributor Author

I've corrected the jsbin link. I found for example this article related to the issue.

Recording of touch device behavior with the patch:

screen-20250102-211517.mp4

@HarelM
Copy link
Collaborator

HarelM commented Jan 3, 2025

Which jsbin has a fix that works on mobile?
My chrome on Android is still showing the hover effect after click...

@digitaltom
Copy link
Contributor Author

The jsbin https://jsbin.com/dedemareco/1/edit?html,output shows the behavior from the fixed video for me.

I've also created: https://jsbin.com/wedujofugo/1/edit?html,css,output which has the full updated CSS from #5285

@HarelM
Copy link
Collaborator

HarelM commented Jan 3, 2025

Using both links I still get this after clicking the + button, on Android (chrome), is this expected?
Image

@digitaltom
Copy link
Contributor Author

I cannot explain this.... This is a video I just recorded of https://jsbin.com/wedujofugo/1/edit?html,css,output with Chrome 131 on Android 15:

screen-20250103-120839.mp4

It works nicely there now.

@HarelM
Copy link
Collaborator

HarelM commented Jan 3, 2025

I have Android 14 but chrome 131 as well... Weird...

@digitaltom
Copy link
Contributor Author

I've also tried on Safari/Ipad now, which shows the fixed behavior. Maybe you can try with Firefox/Chrome DevTools on Desktop, they can emulate touch device behavior too. For me, they also show it fixed.

@HarelM
Copy link
Collaborator

HarelM commented Jan 4, 2025

It's probably an improvement, so I'll merge it as is, you are welcome to continue try and reproduce what I'm seeing on your end to be able to solve this for more devices...

@digitaltom
Copy link
Contributor Author

Thanks for your support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need more info Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants