fix: select option not support click event

pull/3341/head
tanjinzhou 2020-12-09 15:27:03 +08:00
parent 520d6a5e85
commit 4ea00d3a70
3 changed files with 11 additions and 5 deletions

@ -1 +1 @@
Subproject commit ab88ac19de8ce0d3c8a559ad7bcd5fc04532c184 Subproject commit 59408000f682c5495cf3d1106ab07f7c567bbc20

View File

@ -356,16 +356,22 @@ const OptionList = defineComponent<OptionListProps, { state?: any }>({
aria-selected={selected} aria-selected={selected}
class={optionClassName} class={optionClassName}
title={optionTitle} title={optionTitle}
onMousemove={() => { onMousemove={e => {
if (otherProps.onMousemove) {
otherProps.onMousemove(e);
}
if (activeIndex === itemIndex || disabled) { if (activeIndex === itemIndex || disabled) {
return; return;
} }
setActive(itemIndex); setActive(itemIndex);
}} }}
onClick={() => { onClick={e => {
if (!disabled) { if (!disabled) {
onSelectValue(value); onSelectValue(value);
} }
if (otherProps.onClick) {
otherProps.onClick(e);
}
}} }}
style={style} style={style}
> >

View File

@ -10,7 +10,7 @@ function convertNodeToOption(node: VNode): OptionData {
} = node as VNode & { } = node as VNode & {
children: { default?: () => any }; children: { default?: () => any };
}; };
const child = children.default ? children.default() : undefined; const child = children && children.default ? children.default() : undefined;
return { return {
key, key,
value: value !== undefined ? value : key, value: value !== undefined ? value : key,
@ -43,7 +43,7 @@ export function convertChildrenToData(
if (optionOnly || !isSelectOptGroup) { if (optionOnly || !isSelectOptGroup) {
return convertNodeToOption(node); return convertNodeToOption(node);
} }
const child = children.default ? children.default() : undefined; const child = children && children.default ? children.default() : undefined;
return { return {
key: `__RC_SELECT_GRP__${key === null ? index : key}__`, key: `__RC_SELECT_GRP__${key === null ? index : key}__`,
label: key, label: key,