refactor(web): disable nui focus when exiting ui

This commit is contained in:
Luke committed 2023-03-24 21:03:15 +01:00
1 parent e699ffdbcf
commit e2c4841368
1 file changed
+7 -1
+7 -1
View File
@@ -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[];
@@ -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>