Focus map on Esc

This commit is contained in:
James Lyne 2021-05-26 23:55:50 +01:00
parent 76fb05f0b2
commit a7ba49c2c2
2 changed files with 12 additions and 1 deletions

View File

@ -205,6 +205,8 @@ export default defineComponent({
// markerZoomAnimation: false,
})) as DynmapMap;
window.addEventListener('keydown', this.handleKeydown);
this.leaflet.createPane('vectors');
this.leaflet.addControl(new LoadingControl({
@ -221,7 +223,17 @@ export default defineComponent({
});
},
unmounted() {
window.removeEventListener('keydown', this.handleKeydown);
},
methods: {
handleKeydown(e: KeyboardEvent) {
if(e.key === 'Escape') {
e.preventDefault();
this.leaflet.getContainer().focus();
}
},
updateFollow(player: DynmapPlayer, newFollow: boolean) {
const store = useStore(),
followMapName = store.state.configuration.followMap,

View File

@ -114,7 +114,6 @@ export default defineComponent({
const handleEsc = (e: KeyboardEvent) => {
if (e.key === "Escape" && menuVisible.value) {
closeContextMenu();
props.leaflet.getContainer().focus();
}
},
closeContextMenu = () => {