From 4ea00d3a70d0afd7bea07f814df03ab7d0b25ebd Mon Sep 17 00:00:00 2001 From: tanjinzhou <415800467@qq.com> Date: Wed, 9 Dec 2020 15:27:03 +0800 Subject: [PATCH] fix: select option not support click event --- antdv-demo | 2 +- components/vc-select/OptionList.tsx | 10 ++++++++-- components/vc-select/utils/legacyUtil.ts | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/antdv-demo b/antdv-demo index ab88ac19d..59408000f 160000 --- a/antdv-demo +++ b/antdv-demo @@ -1 +1 @@ -Subproject commit ab88ac19de8ce0d3c8a559ad7bcd5fc04532c184 +Subproject commit 59408000f682c5495cf3d1106ab07f7c567bbc20 diff --git a/components/vc-select/OptionList.tsx b/components/vc-select/OptionList.tsx index 26235cb1d..85f61bf4a 100644 --- a/components/vc-select/OptionList.tsx +++ b/components/vc-select/OptionList.tsx @@ -356,16 +356,22 @@ const OptionList = defineComponent({ aria-selected={selected} class={optionClassName} title={optionTitle} - onMousemove={() => { + onMousemove={e => { + if (otherProps.onMousemove) { + otherProps.onMousemove(e); + } if (activeIndex === itemIndex || disabled) { return; } setActive(itemIndex); }} - onClick={() => { + onClick={e => { if (!disabled) { onSelectValue(value); } + if (otherProps.onClick) { + otherProps.onClick(e); + } }} style={style} > diff --git a/components/vc-select/utils/legacyUtil.ts b/components/vc-select/utils/legacyUtil.ts index 2dca628ef..8e1505ef9 100644 --- a/components/vc-select/utils/legacyUtil.ts +++ b/components/vc-select/utils/legacyUtil.ts @@ -10,7 +10,7 @@ function convertNodeToOption(node: VNode): OptionData { } = node as VNode & { children: { default?: () => any }; }; - const child = children.default ? children.default() : undefined; + const child = children && children.default ? children.default() : undefined; return { key, value: value !== undefined ? value : key, @@ -43,7 +43,7 @@ export function convertChildrenToData( if (optionOnly || !isSelectOptGroup) { return convertNodeToOption(node); } - const child = children.default ? children.default() : undefined; + const child = children && children.default ? children.default() : undefined; return { key: `__RC_SELECT_GRP__${key === null ? index : key}__`, label: key,