mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-29 09:00:29 +01:00
Shortcut fixes
- Allow shortcuts to trigger from the shortcut modal - Fix inspect/map toggle shortcut
This commit is contained in:
parent
3d2a1d5d19
commit
bce8e8b807
1 changed files with 15 additions and 7 deletions
|
@ -119,7 +119,9 @@ export default class App extends React.Component {
|
||||||
{
|
{
|
||||||
keyCode: keyCodes["i"],
|
keyCode: keyCodes["i"],
|
||||||
handler: () => {
|
handler: () => {
|
||||||
this.setMapState("inspect");
|
this.setMapState(
|
||||||
|
this.state.mapState === "map" ? "inspect" : "map"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -135,12 +137,13 @@ export default class App extends React.Component {
|
||||||
e.target.blur();
|
e.target.blur();
|
||||||
document.body.focus();
|
document.body.focus();
|
||||||
}
|
}
|
||||||
else if(document.activeElement === document.body) {
|
else if(this.state.isOpen.shortcuts || document.activeElement === document.body) {
|
||||||
const shortcut = shortcuts.find((shortcut) => {
|
const shortcut = shortcuts.find((shortcut) => {
|
||||||
return (shortcut.keyCode === e.keyCode)
|
return (shortcut.keyCode === e.keyCode)
|
||||||
})
|
})
|
||||||
|
|
||||||
if(shortcut) {
|
if(shortcut) {
|
||||||
|
this.setModal("shortcuts", false);
|
||||||
shortcut.handler(e);
|
shortcut.handler(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -484,17 +487,21 @@ export default class App extends React.Component {
|
||||||
this.setState({ selectedLayerIndex: idx })
|
this.setState({ selectedLayerIndex: idx })
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleModal(modalName) {
|
setModal(modalName, value) {
|
||||||
|
if(modalName === 'survey' && value === false) {
|
||||||
|
localStorage.setItem('survey', '');
|
||||||
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
isOpen: {
|
isOpen: {
|
||||||
...this.state.isOpen,
|
...this.state.isOpen,
|
||||||
[modalName]: !this.state.isOpen[modalName]
|
[modalName]: value
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
if(modalName === 'survey') {
|
toggleModal(modalName) {
|
||||||
localStorage.setItem('survey', '');
|
this.setModal(modalName, !this.state.isOpen[modalName]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -549,6 +556,7 @@ export default class App extends React.Component {
|
||||||
|
|
||||||
const modals = <div>
|
const modals = <div>
|
||||||
<ShortcutsModal
|
<ShortcutsModal
|
||||||
|
ref={(el) => this.shortcutEl = el}
|
||||||
isOpen={this.state.isOpen.shortcuts}
|
isOpen={this.state.isOpen.shortcuts}
|
||||||
onOpenToggle={this.toggleModal.bind(this, 'shortcuts')}
|
onOpenToggle={this.toggleModal.bind(this, 'shortcuts')}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in a new issue