fix: the disabled state should not trigger focus (#18012)

* fix: the disabled state should not trigger focus

* fix: update

* chore: update

* chore: update test

* Update packages/hooks/__tests__/use-focus-controller.test.tsx

Co-authored-by: qiang <qw13131wang@gmail.com>

---------

Co-authored-by: qiang <qw13131wang@gmail.com>
This commit is contained in:
btea 2024-08-26 20:46:15 +08:00 committed by GitHub
parent 4fac13c469
commit 19eaae7171
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 1 additions and 8 deletions

View File

@ -117,7 +117,6 @@ describe('useFocusController', () => {
await nextTick()
expect(wrapper.find('span').text()).toBe('false')
expect(wrapper.find('div').attributes('tabindex')).toBe('-1')
expect(focusHandler).not.toHaveBeenCalled()
expect(blurHandler).not.toHaveBeenCalled()

View File

@ -1,4 +1,4 @@
import { getCurrentInstance, onMounted, ref, shallowRef, watch } from 'vue'
import { getCurrentInstance, onMounted, ref, shallowRef } from 'vue'
import { useEventListener } from '@vueuse/core'
import { isElement, isFunction } from '@element-plus/utils'
import type { ShallowRef } from 'vue'
@ -64,12 +64,6 @@ export function useFocusController<T extends { focus: () => void }>(
target.value?.focus()
}
watch(wrapperRef, (el) => {
if (el) {
el.setAttribute('tabindex', '-1')
}
})
useEventListener(wrapperRef, 'focus', handleFocus, true)
useEventListener(wrapperRef, 'blur', handleBlur, true)
useEventListener(wrapperRef, 'click', handleClick, true)