Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/mapml/handlers/ContextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,9 +529,14 @@ export var ContextMenu = L.Handler.extend({
if(!this._mapMenuVisible) return;

let key = e.keyCode;
if(key !== 16 && key!== 9 && !(!this._layerClicked && key === 67) && e.path[0].innerText !== "Copy Coordinates (C) >")
let path = e.path || e.composedPath();

if(key === 13)
e.preventDefault();
if(key !== 16 && key!== 9 && !(!this._layerClicked && key === 67) && path[0].innerText !== "Copy Coordinates (C) >")
this._hide();
switch(key){
case 13: //ENTER KEY
case 32: //SPACE KEY
if(this._map._container.parentNode.activeElement.parentNode.classList.contains("mapml-contextmenu"))
this._map._container.parentNode.activeElement.click();
Expand Down
12 changes: 7 additions & 5 deletions src/mapml/layers/MapLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1290,13 +1290,14 @@ export var MapMLLayer = L.Layer.extend({
}
// When popup is open, what gets focused with tab needs to be done using JS as the DOM order is not in an accessibility friendly manner
function focusFeature(focusEvent){
let path = focusEvent.originalEvent.path || focusEvent.originalEvent.composedPath();
let isTab = focusEvent.originalEvent.keyCode === 9,
shiftPressed = focusEvent.originalEvent.shiftKey;
if((focusEvent.originalEvent.path[0].classList.contains("leaflet-popup-close-button") && isTab && !shiftPressed) || focusEvent.originalEvent.keyCode === 27){
if((path[0].classList.contains("leaflet-popup-close-button") && isTab && !shiftPressed) || focusEvent.originalEvent.keyCode === 27){
L.DomEvent.stop(focusEvent);
map.closePopup(popup);
group.focus();
} else if ((focusEvent.originalEvent.path[0].title==="Focus Map" || focusEvent.originalEvent.path[0].classList.contains("mapml-popup-content")) && isTab && shiftPressed){
} else if ((path[0].title==="Focus Map" || path[0].classList.contains("mapml-popup-content")) && isTab && shiftPressed){
setTimeout(() => { //timeout needed so focus of the feature is done even after the keypressup event occurs
L.DomEvent.stop(focusEvent);
map.closePopup(popup);
Expand All @@ -1306,17 +1307,18 @@ export var MapMLLayer = L.Layer.extend({
}

function focusMap(focusEvent){
let path = focusEvent.originalEvent.path || focusEvent.originalEvent.composedPath();
let isTab = focusEvent.originalEvent.keyCode === 9,
shiftPressed = focusEvent.originalEvent.shiftKey;

if((focusEvent.originalEvent.keyCode === 13 && focusEvent.originalEvent.path[0].classList.contains("leaflet-popup-close-button")) || focusEvent.originalEvent.keyCode === 27 ){
if((focusEvent.originalEvent.keyCode === 13 && path[0].classList.contains("leaflet-popup-close-button")) || focusEvent.originalEvent.keyCode === 27 ){
L.DomEvent.stopPropagation(focusEvent);
map._container.focus();
map.closePopup(popup);
if(focusEvent.originalEvent.keyCode !== 27)map._popupClosed = true;
} else if (isTab && focusEvent.originalEvent.path[0].classList.contains("leaflet-popup-close-button")){
} else if (isTab && path[0].classList.contains("leaflet-popup-close-button")){
map.closePopup(popup);
} else if ((focusEvent.originalEvent.path[0].title==="Focus Map" || focusEvent.originalEvent.path[0].classList.contains("mapml-popup-content")) && isTab && shiftPressed){
} else if ((path[0].title==="Focus Map" || path[0].classList.contains("mapml-popup-content")) && isTab && shiftPressed){
setTimeout(() => { //timeout needed so focus of the feature is done even after the keypressup event occurs
L.DomEvent.stop(focusEvent);
map.closePopup(popup);
Expand Down