Skip to content

Commit

Permalink
refactor(web): disable nui focus when exiting ui
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeWasTakenn committed Mar 24, 2023
1 parent e699ffd commit e2c4841
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion web/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { debugData } from './utils/debugData';
import { visible } from './store';
import { scale } from 'svelte/transition';
import { fetchNui } from './utils/fetchNui';
interface OpenData {
resources: string[];
Expand Down Expand Up @@ -50,7 +51,12 @@
},
]);
const handleESC = (e: KeyboardEvent) => e.key === 'Escape' && ($visible = false);
const handleESC = (e: KeyboardEvent) => {
if (e.key !== 'Escape') return;
$visible = false;
fetchNui('exit');
};
$: $visible ? window.addEventListener('keydown', handleESC) : window.removeEventListener('keydown', handleESC);
</script>
Expand Down

0 comments on commit e2c4841

Please sign in to comment.