I have this:
<AsyncReactSelect
defaultOptions
loadOptions={async () => [
{ value: "Pear", label: "Pear" },
{ value: "Banana", label: "Banana" },
{ value: "Raspberry", label: "Raspberry" },
]}
closeMenuOnSelect={false}
isMulti
/>
that works as I expect. i.e. Pear was selected and the dropdown remained opened
in my test I have
await act(async () => {
// open the dropdown
const selectDropdown = screen.getAllByRole("combobox")[0]
await userEvent.click(selectDropdown)
await screen.findByText("Pear")
screen.debug() // first debug
await userEvent.type(selectDropdown, "{enter}")
screen.debug() // second debug
})
in the first debug, I clear see all the dropdown options in a list
but in the second one, I can never see them and I have no clue as to why. I have tried fireEvent.click
too as I wasn’t sure if something odd was happening in the click functions.
any idea how to solve this?
EDIT:
I added in this and notice it’s being called, it only gets called in the browser when I click outside the menu
onMenuClose={() => {
console.log("called the close!!")
}}
2
Answers
It’s maybe because of this part that this is happening.
Try this:
Further reading here
try this one from
and the options array object structure must need like that
hope this will work on your side