File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed
packages/core/useActiveElement Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change 1
- import { computedWithControl } from '@vueuse/shared '
1
+ import { ref } from 'vue-demi '
2
2
import { useEventListener } from '../useEventListener'
3
3
import type { ConfigurableDocumentOrShadowRoot , ConfigurableWindow } from '../_configurable'
4
4
import { defaultWindow } from '../_configurable'
@@ -36,19 +36,21 @@ export function useActiveElement<T extends HTMLElement>(
36
36
return element
37
37
}
38
38
39
- const activeElement = computedWithControl (
40
- ( ) => null ,
41
- ( ) => getDeepActiveElement ( ) as T | null | undefined ,
42
- )
39
+ const activeElement = ref < T | null | undefined > ( )
40
+ const trigger = ( ) => {
41
+ activeElement . value = getDeepActiveElement ( ) as T | null | undefined
42
+ }
43
43
44
44
if ( window ) {
45
45
useEventListener ( window , 'blur' , ( event ) => {
46
46
if ( event . relatedTarget !== null )
47
47
return
48
- activeElement . trigger ( )
48
+ trigger ( )
49
49
} , true )
50
- useEventListener ( window , 'focus' , activeElement . trigger , true )
50
+ useEventListener ( window , 'focus' , trigger , true )
51
51
}
52
52
53
+ trigger ( )
54
+
53
55
return activeElement
54
56
}
You can’t perform that action at this time.
0 commit comments