chore(components): [dropdown] format (#10465)

refactor(components): [dropdown]

Co-authored-by: qiang <qw13131wang@gmail.com>
This commit is contained in:
Simon He 2024-08-06 22:14:45 +08:00 committed by GitHub
parent 811a2f75cf
commit 96a081b755
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 20 deletions

View File

@ -87,15 +87,10 @@ export default defineComponent({
}) })
) )
const handlePointerLeave = composeEventHandlers( const handlePointerLeave = composeEventHandlers((e: PointerEvent) => {
(e: PointerEvent) => { emit('pointerleave', e)
emit('pointerleave', e) return e.defaultPrevented
return e.defaultPrevented }, whenMouse(onItemLeave))
},
whenMouse((e) => {
onItemLeave(e)
})
)
const handleClick = composeEventHandlers( const handleClick = composeEventHandlers(
(e: PointerEvent) => { (e: PointerEvent) => {
@ -118,9 +113,7 @@ export default defineComponent({
) )
// direct usage of v-bind={ ...$props, ...$attrs } causes type errors // direct usage of v-bind={ ...$props, ...$attrs } causes type errors
const propsAndAttrs = computed(() => { const propsAndAttrs = computed(() => ({ ...props, ...attrs }))
return { ...props, ...attrs }
})
return { return {
handleClick, handleClick,

View File

@ -104,8 +104,8 @@ export default defineComponent({
e.preventDefault() e.preventDefault()
if (target !== unref(contentRef)) return if (target !== unref(contentRef) || !FIRST_LAST_KEYS.includes(code))
if (!FIRST_LAST_KEYS.includes(code)) return return
const items = getItems<{ disabled: boolean }>().filter( const items = getItems<{ disabled: boolean }>().filter(
(item) => !item.disabled (item) => !item.disabled
) )

View File

@ -157,9 +157,7 @@ export default defineComponent({
const trigger = computed(() => ensureArray(props.trigger)) const trigger = computed(() => ensureArray(props.trigger))
const defaultTriggerId = useId().value const defaultTriggerId = useId().value
const triggerId = computed<string>(() => { const triggerId = computed<string>(() => props.id || defaultTriggerId)
return props.id || defaultTriggerId
})
// The goal of this code is to focus on the tooltip triggering element when it is hovered. // The goal of this code is to focus on the tooltip triggering element when it is hovered.
// This is a temporary fix for where closing the dropdown through pointerleave event focuses on a // This is a temporary fix for where closing the dropdown through pointerleave event focuses on a

View File

@ -30,9 +30,7 @@ export const initDropdownDomEvent = (
function removeTabindex() { function removeTabindex() {
triggerElm.setAttribute('tabindex', '-1') triggerElm.setAttribute('tabindex', '-1')
menuItemsArray.value?.forEach((item) => { menuItemsArray.value?.forEach((item) => item.setAttribute('tabindex', '-1'))
item.setAttribute('tabindex', '-1')
})
} }
function resetTabindex(ele) { function resetTabindex(ele) {