From 19eaae71712fa32b84e2cd2756e2097579aac3d4 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Mon, 26 Aug 2024 20:46:15 +0800 Subject: [PATCH] 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 --------- Co-authored-by: qiang --- packages/hooks/__tests__/use-focus-controller.test.tsx | 1 - packages/hooks/use-focus-controller/index.ts | 8 +------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/hooks/__tests__/use-focus-controller.test.tsx b/packages/hooks/__tests__/use-focus-controller.test.tsx index 710b2d074a..4ac7a33e10 100644 --- a/packages/hooks/__tests__/use-focus-controller.test.tsx +++ b/packages/hooks/__tests__/use-focus-controller.test.tsx @@ -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() diff --git a/packages/hooks/use-focus-controller/index.ts b/packages/hooks/use-focus-controller/index.ts index 86bcb80263..3aef3f2ab8 100644 --- a/packages/hooks/use-focus-controller/index.ts +++ b/packages/hooks/use-focus-controller/index.ts @@ -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 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)