fix(menu): when responsive prop is set, attrs can't be inherited correctly (#5942)

当menu添加responsive后,其上的属性无法透传至正确的位置

Co-authored-by: 07akioni <07akioni2@gmail.com>
This commit is contained in:
xiyueW 2024-07-29 00:08:03 +08:00 committed by GitHub
parent c37c2b2f97
commit 84921f3274
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -10,7 +10,8 @@ import {
provide,
ref,
toRef,
watchEffect
watchEffect,
mergeProps
} from 'vue'
import { type Key, createTreeMate } from 'treemate'
import { useCompitable, useMergedState } from 'vooks'
@ -627,16 +628,17 @@ export default defineComponent({
const horizontal = mode === 'horizontal'
const finalResponsive = horizontal && this.responsive
const renderMainNode = (): VNode => (
<div
role={mode === 'horizontal' ? 'menubar' : 'menu'}
class={[
`${mergedClsPrefix}-menu`,
themeClass,
`${mergedClsPrefix}-menu--${mode}`,
finalResponsive && `${mergedClsPrefix}-menu--responsive`,
this.mergedCollapsed && `${mergedClsPrefix}-menu--collapsed`
]}
style={this.cssVars}
<div {...mergeProps(this.$attrs, {
role: mode === 'horizontal' ? 'menubar' : 'menu',
class: [
`${mergedClsPrefix}-menu`,
themeClass,
`${mergedClsPrefix}-menu--${mode}`,
finalResponsive && `${mergedClsPrefix}-menu--responsive`,
this.mergedCollapsed && `${mergedClsPrefix}-menu--collapsed`
],
style: this.cssVars
})}
>
{finalResponsive ? (
<VOverflow