-
Use caseI want to build a "click to tag a product" button that will activate AA in detached mode. Current behaviorWhen in detached mode, the default trigger component is an HTML button that looks like a search box. I want to replace this button with my own. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hi, you can use the const { setIsOpen } = autocomplete({
// ...
openOnFocus: true,
});
/* ... */
tagBtn.addEventListener('click', () => {
setIsOpen(true);
}); |
Beta Was this translation helpful? Give feedback.
-
@dhayab thanks for your help. I can programmatically trigger the search in detached mode. However, the default trigger button is still being rendered. How do I hide it or replace it with my own component? PS: My component is nearly identical to the React 18 sample code. |
Beta Was this translation helpful? Give feedback.
Hi, you can use the
setIsOpen()
state setter, returned byautocomplete()
, to programmaticaly open the detached panel. For this to work correctly you'll also need to configure autocomplete withopenOnFocus: true
.