-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Don't overwrite browser zoom shortcuts #14946
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution! I‘d suggest fixing this directly in KeybordZoom.js, because it‘s the documented and expected behavior.
True - I adjusted the code according to your suggestion. |
📦 Preview the website for this branch here: https://deploy-preview-14946--ol-site.netlify.app/. |
Many keyboard layouts use the shift key to access
|
That's a good point! I extended the filter criteria to allow |
src/ol/interaction/KeyboardZoom.js
Outdated
: function (mapBrowserEvent) { | ||
return ( | ||
(noModifierKeys(mapBrowserEvent) || | ||
shiftKeyOnly(mapBrowserEvent)) && | ||
targetNotEditable(mapBrowserEvent) | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not simply
: function (mapBrowserEvent) { | |
return ( | |
(noModifierKeys(mapBrowserEvent) || | |
shiftKeyOnly(mapBrowserEvent)) && | |
targetNotEditable(mapBrowserEvent) | |
); | |
}; | |
: (mapBrowserEvent) => !platformModifierKeyOnly(mapBrowserEvent) && targetNotEditable(mapBrowserEvent) |
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On keyboards which need shift to type + browser zoom needs ctrl shift.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(although on Windows Chrome with UK keyboard ctrl = will also activate browser zoom).
@fjellfly I think having a |
Some browsers enable the user to set the zoomlevel of the website using `ctrl` and `+` or `-`. The default version of `KeyboardZoom` catches these keydown events and adjusts the map zoomlevel. There might be a situation where a user wants to increase or decrease the size of e.g. the controls as well. They are not able to do this via shortcuts because they are handled by OpenLayers. To get around this the default `KeyboardZoom` should only adjust the zoom level if `+` or `-` was pressed without `ctrl` being pressed at the same time. This way, the event is raised to the browser if `ctrl` was pressed, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @fjellfly, for this excellent first-time contribution.
@fjellfly There is a minor issue with the new test: on a Mac, it will fail. Instead of testing with the Ctrl key hard coded, the Ctrl or Cmd key should be used, depending on the platform. Would be great if you could create a small follow-up pull request to fix that. |
|
Some browsers enable the user to set the zoomlevel of the website using
Ctrl
and+
or-
. The default version ofKeyboardZoom
catches these keydown events and adjusts the map zoomlevel. There might be a situation where a user wants to increase or decrease the size of e.g. the controls as well. They are not able to do this via shortcuts because they are handled by OpenLayers. To get around this, I suggest that the defaultKeyboardZoom
should only adjust the zoom level if+
or-
was pressed withoutCtrl
being pressed at the same time. This way, the event is raised to the browser ifCtrl
was pressed, too.