I am trying to use this dropdown menu code from tailwindcss. I can hide the dropdown and show it on button press using the following code.
@if (menuOpen)
{
....
}
@code {
bool menuOpen;
void ToggleMenu()
{
menuOpen = !menuOpen;
StateHasChanged();
}
}
How to close the dropdown menu when the user clicks on something else on the site?
I tried to use onblur
event but that prevents me from clicking on the menu items in the first place.