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 '
22import { useEventListener } from '../useEventListener'
33import type { ConfigurableDocumentOrShadowRoot , ConfigurableWindow } from '../_configurable'
44import { defaultWindow } from '../_configurable'
@@ -36,19 +36,21 @@ export function useActiveElement<T extends HTMLElement>(
3636 return element
3737 }
3838
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+ }
4343
4444 if ( window ) {
4545 useEventListener ( window , 'blur' , ( event ) => {
4646 if ( event . relatedTarget !== null )
4747 return
48- activeElement . trigger ( )
48+ trigger ( )
4949 } , true )
50- useEventListener ( window , 'focus' , activeElement . trigger , true )
50+ useEventListener ( window , 'focus' , trigger , true )
5151 }
5252
53+ trigger ( )
54+
5355 return activeElement
5456}
You can’t perform that action at this time.
0 commit comments