File tree 1 file changed +15
-2
lines changed
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -4,13 +4,28 @@ import { Checkbox } from "@/components"
4
4
import { useArenaStore } from " ./store"
5
5
import { storeToRefs } from " pinia"
6
6
import { watchEffect } from " vue"
7
+ import { useDialogObserver } from " @/hooks"
7
8
8
9
const arenaStore = useArenaStore ()
9
10
const { shouldAutoFocusGenerate } = storeToRefs (arenaStore )
10
11
11
12
const buttons = Array .from (document .querySelectorAll <HTMLButtonElement >(" .col-span-2 button" ))
12
13
const generateButton = buttons .find ((b ) => b .innerText .toLowerCase ().includes (" generate" ))
13
14
15
+ useDialogObserver ({
16
+ toggle: shouldAutoFocusGenerate ,
17
+ onOpen : ({ el }) => {
18
+ const button = el .querySelector <HTMLButtonElement >(" button.w-full.justify-center.rounded-md" )
19
+ if (! button ) return
20
+ if (! [" generate" , " battle" ].some ((key ) => button .innerText .toLowerCase ().includes (key ))) return
21
+
22
+ const TRANSITION_TIMEOUT = 200
23
+ setTimeout (() => {
24
+ button .focus ()
25
+ }, TRANSITION_TIMEOUT )
26
+ },
27
+ })
28
+
14
29
watchEffect (() => {
15
30
if (! generateButton ) return
16
31
if (! shouldAutoFocusGenerate .value ) return
@@ -25,5 +40,3 @@ watchEffect(() => {
25
40
<template #subtitle > Just hit space/enter! </template >
26
41
</Checkbox >
27
42
</template >
28
-
29
- <style lang="scss" scoped></style >
You can’t perform that action at this time.
0 commit comments