Skip to content

Commit c20c1f2

Browse files
committed
fix: dropdown submenu style error #4351
close #4351
1 parent fb94726 commit c20c1f2

File tree

5 files changed

+15
-6
lines changed

5 files changed

+15
-6
lines changed

components/dropdown/dropdown.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const Dropdown = defineComponent({
6363
// menu should be focusable in dropdown defaultly
6464
const overlayProps = overlayNode && getPropsData(overlayNode);
6565
const { selectable = false, focusable = true } = (overlayProps || {}) as any;
66-
const expandIcon = (
66+
const expandIcon = () => (
6767
<span class={`${prefixCls}-menu-submenu-arrow`}>
6868
<RightOutlined class={`${prefixCls}-menu-submenu-arrow-icon`} />
6969
</span>

components/dropdown/style/index.less

+3-1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@
6868
&-submenu-popup {
6969
position: absolute;
7070
z-index: @zindex-dropdown;
71+
background: transparent;
72+
box-shadow: none;
73+
transform-origin: 0 0;
7174

7275
> .@{dropdown-prefix-cls}-menu {
7376
transform-origin: 0 0;
@@ -81,7 +84,6 @@
8184
ul {
8285
margin-right: 0.3em;
8386
margin-left: 0.3em;
84-
padding: 0;
8587
}
8688
}
8789

components/menu/src/Menu.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ export const menuProps = {
4949
triggerSubMenuAction: { type: String as PropType<TriggerSubMenuAction>, default: 'hover' },
5050

5151
getPopupContainer: Function as PropType<(node: HTMLElement) => HTMLElement>,
52+
53+
expandIcon: Function as PropType<(p?: { isOpen: boolean; [key: string]: any }) => any>,
5254
};
5355

5456
export type MenuProps = Partial<ExtractPropTypes<typeof menuProps>>;
@@ -66,6 +68,7 @@ export default defineComponent({
6668
'click',
6769
'update:activeKey',
6870
],
71+
slots: ['expandIcon'],
6972
setup(props, { slots, emit }) {
7073
const { prefixCls, direction } = useConfigInject('menu', props);
7174
const store = ref<Record<string, StoreMenuInfo>>({});
@@ -371,6 +374,7 @@ export default defineComponent({
371374
unRegisterMenuInfo,
372375
selectedSubMenuEventKeys,
373376
isRootMenu: true,
377+
expandIcon: props.expandIcon || slots.expandIcon,
374378
});
375379
return () => {
376380
const childList = flattenChildren(slots.default?.());

components/menu/src/SubMenu.tsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const subMenuProps = {
2424
popupOffset: Array as PropType<number[]>,
2525
internalPopupClose: Boolean,
2626
eventKey: String,
27+
expandIcon: Function as PropType<(p?: { isOpen: boolean; [key: string]: any }) => any>,
2728
};
2829

2930
export type SubMenuProps = Partial<ExtractPropTypes<typeof subMenuProps>>;
@@ -32,7 +33,7 @@ export default defineComponent({
3233
name: 'ASubMenu',
3334
inheritAttrs: false,
3435
props: subMenuProps,
35-
slots: ['icon', 'title'],
36+
slots: ['icon', 'title', 'expandIcon'],
3637
emits: ['titleClick', 'mouseenter', 'mouseleave'],
3738
setup(props, { slots, attrs, emit }) {
3839
useProvideFirstLevel(false);
@@ -84,6 +85,7 @@ export default defineComponent({
8485
selectedSubMenuEventKeys,
8586
motion,
8687
defaultMotions,
88+
expandIcon: menuExpandIcon,
8789
} = useInjectMenu();
8890

8991
registerMenuInfo(eventKey, menuInfo);
@@ -226,6 +228,7 @@ export default defineComponent({
226228
const icon = getPropsSlot(slots, props, 'icon');
227229
const title = renderTitle(getPropsSlot(slots, props, 'title'), icon);
228230
const subMenuPrefixClsValue = subMenuPrefixCls.value;
231+
const expandIcon = props.expandIcon || slots.expandIcon || menuExpandIcon;
229232
let titleNode = (
230233
<div
231234
style={directionStyle.value}
@@ -244,8 +247,8 @@ export default defineComponent({
244247
{title}
245248

246249
{/* Only non-horizontal mode shows the icon */}
247-
{mode.value !== 'horizontal' && slots.expandIcon ? (
248-
slots.expandIcon({ ...props, isOpen: open.value })
250+
{mode.value !== 'horizontal' && expandIcon ? (
251+
expandIcon({ ...props, isOpen: open.value })
249252
) : (
250253
<i class={`${subMenuPrefixClsValue}-arrow`} />
251254
)}

components/menu/src/hooks/useMenuContext.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export interface MenuContextProps {
7777

7878
// // Icon
7979
// itemIcon?: RenderIconType;
80-
// expandIcon?: RenderIconType;
80+
expandIcon?: (p?: { isOpen: boolean; [key: string]: any }) => any;
8181

8282
// // Function
8383
onItemClick: MenuClickEventHandler;

0 commit comments

Comments
 (0)