Skip to content

Commit

Permalink
fix: [select] 修复onDeselect回调事件触发时机错误问题 fix kingdee#949
Browse files Browse the repository at this point in the history
  • Loading branch information
liangfeng_wang committed Nov 26, 2024
1 parent 9d9d88f commit a9e808a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions components/select/option.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ const InternalOption: React.ForwardRefRenderFunction<unknown, ISelectOptionProps
})
const handleClick = (e: React.MouseEvent<HTMLDivElement>) => {
e.preventDefault()
let newVal = isSelected
if (optionProps.disabled || value === undefined) return
if (isMultiple) {
setSelected(!isSelected)
newVal = !isSelected
setSelected(newVal)
}
onChangeSelect && onChangeSelect(value, children, isSelected)
onChangeSelect && onChangeSelect(value, children, newVal)
}
const handleOnMouseEnter = () => {
onChangeActiveIndex && onChangeActiveIndex(index)
Expand Down
6 changes: 5 additions & 1 deletion components/select/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,11 @@ const InternalSelect: React.ForwardRefRenderFunction<ISelectProps<SelectValue>>
if (!item) return
const key = item.props?.value || item.value
const label = item.props?.children || item.label
handleOption(key, label, true)
let flag = true
if (isMultiple) {
flag = !mulOptions?.some((item: any) => item.value === key)
}
handleOption(key, label, flag)
// search
if (searchValue) {
setActiveIndex(
Expand Down

0 comments on commit a9e808a

Please sign in to comment.