Keep search text after selected one facet value

I made a customized RefinementList with connectRefinementList, I can input the search text in the search box, then it will return filtered facets, but after I selected one facet value, the facet list will be re-rendered without using the search text to filter the facet values.

I found that the facet filter is calling the searchForItems; after the facet selection, it calls the refine method to do a search for data. It’s impossible for me to pass the current search text into the refine method.

I tried to call searchForItems after the refine call, but that doesn’t work, I guess it’s because the call order and response order are not guaranteed .

My component is similar to the Brand facet filer on this demo, just kept the search text after selection.
https://react-instantsearch.netlify.app/examples/e-commerce/search/?query=a&brands=Apple&brands=Best%20Buy%20GC&brands=Epson

Is there a way to achieve this? Thanks

I figured it out, there is a prop isFromSearch for the connectRefinementList, after selected a facet value, isFromSearch will be false, then I can check if it’s false and the searchText is not empty, I will trigger refine(searchText) another search. Before the new request back, I made the search result list empty, so it won’t have the issue show a different list of facet values before the data back.