'Antd AutoComplete with suffix: how to avoid the opening of dropdown with suggested options when clicking on suffix component?
How to prevent opening the dropdown with suggested options when clicking on suffix component?
...
const options = [{ value: "a" }, { value: "aa" }, { value: "aaa" }];
const onClick = (e) => {
console.log("Help");
e.preventDefault();
e.stopPropagation();
};
const Suffix = <div onClick={onClick}>Help</div>;
return (
<AutoComplete
options={options}
style={{ width: 200 }}
onSelect={onSelect}
onSearch={onSearch}
onDropdownVisibleChange={(v) => console.log("onDropdownVisibleChange", v)}
>
<Input suffix={Suffix} />
</AutoComplete>
);
Use of "open" prop for controlling the dropdown state of AutoComplete component doesn't allow me to reach the goal: even though I set "open" to false into "onClick" handler, you can notice opening and closing animation of AutoComplete component when you click on "Help" ("onDropdownVisibleChange" is handled before "onClick").
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
