[SOLVED] Reset dropdown options in web3uikit modal

Hello good people,

I would like to kindly ask you how to reset Dropdown menu in the web3uikit modal once the modal is closed, canceled or fired a subsequent action? Right now, it keeps returning the previously selected option.

Thank you very much in advance!

cities = [
            {
              id: 'New York',
              label: 'New York'
            },
            {
              id: 'Toronto',
              label: 'Toronto'
            },
]
return (
        <Modal
            title="Select token ID"
            isVisible={isVisible}
            onCancel={onClose}
            onCloseButtonPressed={onClose}
            onOk={handleOnOk}
        >
            <div">
                <Dropdown label="Selected NFT ID: " options={cities} onChange={handleOnChange} />
            </div>
        </Modal>
    )

Looks like you can use the selectedState prop in Dropdown. So you can set it to -1 on close/cancel using a state, and it will reset back to the initial one.

You can also post on the #web3uikit channel on the Moralis Discord, the developers check it regularly.

1 Like

Oh, I completely missed the Dropdown section - I should improve my searching skills :man_facepalming: . I think it is rather defaultOptionIndex prop but thank you very much!