File tree 4 files changed +44
-3
lines changed
4 files changed +44
-3
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,6 @@ defineProps<{
14
14
15
15
<style lang="scss" scoped>
16
16
.controls {
17
- margin-top : 1rem ;
17
+ margin : 1rem 0 ;
18
18
}
19
19
</style >
Original file line number Diff line number Diff line change
1
+ <script setup lang="ts">
2
+ import { Checkbox } from " @/components"
3
+ import { useMarketStore } from " ./store"
4
+ import { storeToRefs } from " pinia"
5
+ import { watchEffect } from " vue"
6
+ import { useSwalObserver } from " @/hooks"
7
+
8
+ const { shouldAutoFocusFirstItem } = storeToRefs (useMarketStore ())
9
+
10
+ function selectFirstButton() {
11
+ const firstButton = document .querySelector <HTMLButtonElement >(" tbody button" )
12
+ firstButton ?.focus ()
13
+ }
14
+
15
+ useSwalObserver ({
16
+ toggle: shouldAutoFocusFirstItem ,
17
+ onReject(el ) {
18
+ if (el .innerText .includes (" sold" )) window .location .reload ()
19
+ },
20
+ onClose() {
21
+ selectFirstButton ()
22
+ },
23
+ })
24
+
25
+ watchEffect (() => {
26
+ if (shouldAutoFocusFirstItem .value ) selectFirstButton ()
27
+ })
28
+ </script >
29
+
30
+ <template >
31
+ <Checkbox v-model =" shouldAutoFocusFirstItem" >
32
+ <template #default > Autofocus first item </template >
33
+ <template #subtitle > Press space them bulk purchases </template >
34
+ </Checkbox >
35
+ </template >
Original file line number Diff line number Diff line change 1
1
<script setup lang="ts">
2
+ import Autofocus from " ./Autofocus.vue"
2
3
import { Controls } from " @/components"
3
4
import { onBeforeMount } from " vue"
4
5
@@ -17,6 +18,6 @@ onBeforeMount(() => {
17
18
18
19
<template >
19
20
<Controls :to =" `#${marketControlsId}`" >
20
- <div style = " color : white " >web-app-container</ div >
21
+ <Autofocus / >
21
22
</Controls >
22
23
</template >
Original file line number Diff line number Diff line change 1
1
import { defineStore } from "pinia"
2
+ import { ref } from "vue"
2
3
3
4
export const useMarketStore = defineStore (
4
5
"market" ,
5
6
( ) => {
6
- return { }
7
+ const shouldAutoFocusFirstItem = ref ( false )
8
+
9
+ return {
10
+ shouldAutoFocusFirstItem,
11
+ }
7
12
} ,
8
13
{
9
14
persist : true ,
You can’t perform that action at this time.
0 commit comments