Dropdown cannot be opened again, if closed by clicking on the trigger button
See original GitHub issueRelevant code or config:
import React, { useState } from "react";
import { Dropdown, DropdownItem } from "@windmill/react-ui";
interface Props {}
const UserDropdown = (props: Props) => {
const [isProfileMenuOpen, setIsProfileMenuOpen] = useState(false);
function handleProfileClick() {
setIsProfileMenuOpen(!isProfileMenuOpen);
}
return (<div className="relative">
<button
className="rounded-full focus:shadow-outline-purple focus:outline-none"
onClick={handleProfileClick}
aria-label="Account"
aria-haspopup="true"
>
Toggle
</button>
<Dropdown
align="right"
isOpen={isProfileMenuOpen}
onClose={() => {
setIsProfileMenuOpen(false);
}}
>
<DropdownItem tag="a" href="#">
User
</DropdownItem>
<DropdownItem tag="a" href="#">
Settings
</DropdownItem>
<DropdownItem onClick={() => alert("Signout")}>
Logout
</DropdownItem>
</Dropdown>
</div>)
}
export default UserDropdown;
What you did:
Implemented a dropdown according to the full example of the documentation https://windmillui.com/react-ui/components/dropdown
What happened:
On first render, when user clicks on toggle button, then dropdown pops up. When user clicks the toggle button again, then the dropdown is closed. After the second click the dropdown cannot be opened again and remains closed.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7
Top Results From Across the Web
Cannot re-open the drop-down list by one click
There is a drop-down list and an iframe . The problem is that when the drop-down list is open, clicking on the iframe...
Read more >Video: Trigger an animation effect - Microsoft Support
In the Animation Pane, select the animated shape or other object that you want to trigger to begin playing when you click it....
Read more >Manage objects with the Selection pane
In the pane, select an item in the list. On the right side of the item, click the "open eye" button. The Open...
Read more >Dropdowns · Bootstrap
Wrap the dropdown's toggle (your button or link) and the dropdown menu within .dropdown , or another element that declares position: relative; ....
Read more >How to Create a Dropdown Menu in Adobe XD
Dropdown menus typically have two core states; open and closed. ... With the newly created component selected, click on the + button next...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Update
@estevanmaito when debouncing the onClose handler of the Dropdown component the issue is solved. e.g.
Not sure why, but forcing the button to be re-mounted when changing
isOpen
seems to fix this issue. The easiest way to do this is setting akey
prop on the button that changes withisOpen
(I usedkey={isOpen.toString()}
).