Skip to content

Commit

Permalink
fix(dropdown-menu): 修复DropdownItem组件不受控 (#1145)
Browse files Browse the repository at this point in the history
fix #1139
  • Loading branch information
yiqia authored Oct 30, 2023
1 parent db1c2df commit 3b7400c
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/dropdown-menu/dropdown-menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,19 @@ export default defineComponent({
const { keys, label, value, modelValue, defaultValue, disabled, options } = item.props;
const currentValue = value || modelValue || defaultValue;
const target = options?.find((item: any) => item[keys?.value ?? 'value'] === currentValue);
if (state.itemsLabel.length < index + 1) {
if (!label) {
state.itemsLabel.push((target && target[keys?.label ?? 'label']) || '');
} else {
state.itemsLabel.push(label || '');
}
const computedLabel = target?.[keys?.label ?? 'label'] || '';
const targetLabel = (target && target[keys?.label ?? 'label']) || '';
const computedLabel = label || targetLabel;
state.itemsLabel.push(computedLabel);
return {
label: label || computedLabel,
label: computedLabel,
disabled: disabled !== undefined && disabled !== false,
};
}
return {
label: label || menuTitles.value[index].label,
label: label || target.label,
disabled: disabled !== undefined && disabled !== false,
};
}),
Expand Down Expand Up @@ -124,6 +122,7 @@ export default defineComponent({
}
props.onMenuOpened?.('menuOpened');
state.activeId = idx;
state.itemsLabel[idx] = item.label;
// 获取菜单定位
const bar = refBar.value as any;
Expand Down

0 comments on commit 3b7400c

Please sign in to comment.