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

View File

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

View File

@ -157,9 +157,7 @@ export default defineComponent({
const trigger = computed(() => ensureArray(props.trigger))
const defaultTriggerId = useId().value
const triggerId = computed<string>(() => {
return props.id || defaultTriggerId
})
const triggerId = computed<string>(() => props.id || defaultTriggerId)
// 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

View File

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