Skip to content

Commit

Permalink
fix(SearchTree): 下拉弹层没有展开时,清空搜索内容不再展开弹层 #584 (#585)
Browse files Browse the repository at this point in the history
  • Loading branch information
nullptr-z committed Mar 2, 2022
1 parent 62026a7 commit 099d488
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/react-search-tree/src/SearchTagInput.tsx
Expand Up @@ -51,7 +51,7 @@ function SearchTagInput<V extends SearchTagInputOption>(props: SearchTagInputPro

const cls = [prefixCls, className].filter(Boolean).join(' ').trim();
// const isMultiple = useMemo(() => mode === 'multiple', [mode]);
// const [innerIsOpen, setInnerIsOpen] = useState(false);
const [innerIsOpen, setInnerIsOpen] = useState(false);
const [selectedOption, setSelectedOption] = useState<Array<V>>(values);
const optionRef = useRef<Array<V>>();
const [searchValue, searchValueSet] = useState<string>('');
Expand Down Expand Up @@ -89,7 +89,7 @@ function SearchTagInput<V extends SearchTagInputOption>(props: SearchTagInputPro

// 清除选中的值
function resetSelectedValue() {
// setInnerIsOpen(false);
setInnerIsOpen(false);
setSelectedOption([]);
handleInputChange('');
handleSelectChange([]);
Expand All @@ -112,11 +112,13 @@ function SearchTagInput<V extends SearchTagInputOption>(props: SearchTagInputPro
}, [selectedOption, options]);

return (
<Dropdown className={cls} trigger="focus" {...others} menu={<Card>{newContent}</Card>}>
<Dropdown className={cls} trigger="focus" {...others} isOpen={innerIsOpen} menu={<Card>{newContent}</Card>}>
<div
onMouseOver={() => renderSelectIcon('enter')}
onMouseLeave={() => renderSelectIcon('leave')}
onClick={() => inputRef.current?.focus()}
onClick={() => {
if (innerIsOpen) inputRef.current?.focus();
}}
style={{ minWidth: 200, maxWidth: 'none', ...style }}
>
<div className={`${prefixCls}-inner`}>
Expand Down

0 comments on commit 099d488

Please sign in to comment.