File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change 6
6
onBeforeUnmount ,
7
7
defineProps ,
8
8
defineEmits ,
9
- onMounted
9
+ onMounted ,
10
+ nextTick
10
11
} from " vue" ;
11
12
import { useLocalStorage } from " @vueuse/core" ;
12
13
import " highlight.js/styles/github.css" ;
@@ -53,17 +54,17 @@ const renderer = ref(props.renderer);
53
54
const source = ref (null );
54
55
watch (
55
56
() => props .open ,
56
- val => {
57
+ async val => {
57
58
if (val) {
58
59
renderer .value = props .renderer ;
59
60
}
60
61
61
- setTimeout (() => {
62
- if ( initializing . value ) {
63
- return ;
64
- }
65
- source . value ? . focus ();
66
- } );
62
+ await nextTick ();
63
+
64
+ if ( initializing . value ) {
65
+ return ;
66
+ }
67
+ source . value ? . focus ( );
67
68
}
68
69
);
69
70
@@ -78,6 +79,9 @@ onMounted(async () => {
78
79
});
79
80
80
81
initializing .value = false ;
82
+
83
+ await nextTick ();
84
+
81
85
source .value ? .focus ();
82
86
});
83
87
You can’t perform that action at this time.
0 commit comments