I have created a dropdown menu using HTML <select>
and <option>
tags, along with a JavaScript function that triggers a confirmation dialogue when an option is selected. The confirmation offers a simple choice between "yes" or "no."
If the user selects "yes," the current state will be updated to the chosen option from the dropdown. Choosing "no" will keep the state unchanged.
The issue I am facing is that after selecting "no," the dropdown menu remains highlighting the option that was rejected. Is there a way for the dropdown menu to revert back to showing the current state instead?
Here is a link to my StackBlitz project demonstrating the problem
UPDATE
While some of the responses provided useful insights, one aspect that was not addressed is that the state
does not display the disabled
option if it does not have an assigned value.