-
-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dropdown component toggle methods (ToggleAsync etc.) not working as expected #1025
Comments
@MarcinWatroba Thank you for using BlazorBootstrap. There is no need to write the Please follow the demos at BlazorBootstrap Dropdown Demos. Example 1:<div class="d-flex gap-2 mb-4">
<Dropdown Color="DropdownColor.Primary">
<DropdownToggleButton>Primary</DropdownToggleButton>
<DropdownMenu>
<DropdownItem To="#" Type="DropdownItemType.Link">Action</DropdownItem>
<DropdownItem To="#" Type="DropdownItemType.Link">Another action</DropdownItem>
<DropdownItem To="#" Type="DropdownItemType.Link">Something else here</DropdownItem>
</DropdownMenu>
</Dropdown>
<Dropdown Color="DropdownColor.Secondary">
<DropdownToggleButton>Secondary</DropdownToggleButton>
<DropdownMenu>
<DropdownItem To="#" Type="DropdownItemType.Link">Action</DropdownItem>
<DropdownItem To="#" Type="DropdownItemType.Link">Another action</DropdownItem>
<DropdownItem To="#" Type="DropdownItemType.Link">Something else here</DropdownItem>
</DropdownMenu>
</Dropdown>
<Dropdown Color="DropdownColor.Success">
<DropdownToggleButton>Success</DropdownToggleButton>
<DropdownMenu>
<DropdownItem To="#" Type="DropdownItemType.Link">Action</DropdownItem>
<DropdownItem To="#" Type="DropdownItemType.Link">Another action</DropdownItem>
<DropdownItem To="#" Type="DropdownItemType.Link">Something else here</DropdownItem>
</DropdownMenu>
</Dropdown>
<Dropdown Color="DropdownColor.Info">
<DropdownToggleButton>Info</DropdownToggleButton>
<DropdownMenu>
<DropdownItem To="#" Type="DropdownItemType.Link">Action</DropdownItem>
<DropdownItem To="#" Type="DropdownItemType.Link">Another action</DropdownItem>
<DropdownItem To="#" Type="DropdownItemType.Link">Something else here</DropdownItem>
</DropdownMenu>
</Dropdown>
<Dropdown Color="DropdownColor.Warning">
<DropdownToggleButton>Warning</DropdownToggleButton>
<DropdownMenu>
<DropdownItem To="#" Type="DropdownItemType.Link">Action</DropdownItem>
<DropdownItem To="#" Type="DropdownItemType.Link">Another action</DropdownItem>
<DropdownItem To="#" Type="DropdownItemType.Link">Something else here</DropdownItem>
</DropdownMenu>
</Dropdown>
<Dropdown Color="DropdownColor.Danger">
<DropdownToggleButton>Danger</DropdownToggleButton>
<DropdownMenu>
<DropdownItem To="#" Type="DropdownItemType.Link">Action</DropdownItem>
<DropdownItem To="#" Type="DropdownItemType.Link">Another action</DropdownItem>
<DropdownItem To="#" Type="DropdownItemType.Link">Something else here</DropdownItem>
</DropdownMenu>
</Dropdown>
</div> Example 2: Split button<div class="d-flex gap-2 mb-4">
<Dropdown Color="DropdownColor.Primary" Split="true">
<DropdownActionButton>Primary</DropdownActionButton>
<DropdownToggleButton />
<DropdownMenu>
<DropdownItem To="#" Type="DropdownItemType.Link">Action</DropdownItem>
<DropdownItem To="#" Type="DropdownItemType.Link">Another action</DropdownItem>
<DropdownItem To="#" Type="DropdownItemType.Link">Something else here</DropdownItem>
</DropdownMenu>
</Dropdown>
<Dropdown Color="DropdownColor.Secondary" Split="true">
<DropdownActionButton>Secondary</DropdownActionButton>
<DropdownToggleButton />
<DropdownMenu>
<DropdownItem To="#" Type="DropdownItemType.Link">Action</DropdownItem>
<DropdownItem To="#" Type="DropdownItemType.Link">Another action</DropdownItem>
<DropdownItem To="#" Type="DropdownItemType.Link">Something else here</DropdownItem>
</DropdownMenu>
</Dropdown>
<Dropdown Color="DropdownColor.Success" Split="true">
<DropdownActionButton>Success</DropdownActionButton>
<DropdownToggleButton />
<DropdownMenu>
<DropdownItem To="#" Type="DropdownItemType.Link">Action</DropdownItem>
<DropdownItem To="#" Type="DropdownItemType.Link">Another action</DropdownItem>
<DropdownItem To="#" Type="DropdownItemType.Link">Something else here</DropdownItem>
</DropdownMenu>
</Dropdown>
<Dropdown Color="DropdownColor.Info" Split="true">
<DropdownActionButton>Info</DropdownActionButton>
<DropdownToggleButton />
<DropdownMenu>
<DropdownItem To="#" Type="DropdownItemType.Link">Action</DropdownItem>
<DropdownItem To="#" Type="DropdownItemType.Link">Another action</DropdownItem>
<DropdownItem To="#" Type="DropdownItemType.Link">Something else here</DropdownItem>
</DropdownMenu>
</Dropdown>
<Dropdown Color="DropdownColor.Warning" Split="true">
<DropdownActionButton>Warning</DropdownActionButton>
<DropdownToggleButton />
<DropdownMenu>
<DropdownItem To="#" Type="DropdownItemType.Link">Action</DropdownItem>
<DropdownItem To="#" Type="DropdownItemType.Link">Another action</DropdownItem>
<DropdownItem To="#" Type="DropdownItemType.Link">Something else here</DropdownItem>
</DropdownMenu>
</Dropdown>
<Dropdown Color="DropdownColor.Danger" Split="true">
<DropdownActionButton>Danger</DropdownActionButton>
<DropdownToggleButton />
<DropdownMenu>
<DropdownItem To="#" Type="DropdownItemType.Link">Action</DropdownItem>
<DropdownItem To="#" Type="DropdownItemType.Link">Another action</DropdownItem>
<DropdownItem To="#" Type="DropdownItemType.Link">Something else here</DropdownItem>
</DropdownMenu>
</Dropdown>
</div> I hope the demos will help. Let me know if you are still facing any issues. |
@gvreddy04 Thanks for speedy reply, however, this doesn't solve the problem. Let's take the dropdown form demo you have on your website as an example. When you copy the code and run it for yourself there's an issue right out of the box. The form has validation, however user doesn't get to see validation messages because as soon as the submit button is clicked, or user clicks anywhere in the dropdown menu for that matter, the dropdown closes. To fix this I add the AutoCloseBehavior=Outside parameter, now dropdown doesn't close down when user clicks the submit button. Next step is to close the dropdown on submit only if validation passes and form is submitted successfully. For this to work you need to use the manual dropdown hide method. So you add the Dropdown variable, reference it, and call HideAsync() method in HandleOnValidSubmit(). This works great if you have just one dropdown, try adding another dropdown before this form dropdown, the HideAsync will no longer work because it will trigger on the first dropdown instead on the one that's referenced. |
Here's example, your edit form sample code combined with the extra bits I added, try expanding Dropdown A, then expand Dropdown form and click on the Submit button, Dropdown A will close instead of Dropdown form:
|
@MarcinWatroba Thank you for the detailed information. I will take a look. |
Description
Dropdown component toggle methods such as ToggleAsync and ShowAsync always display dropdown menu of the first dropdown component in the page. This occurs in global server side rendering (haven't tested other types of rendering).
Example: You have Dropdown A and Dropdown B, with their respective menus, Menu A and Menu B.
When calling ToggleAsync method on either Dropdown A or Dropdown B, Dropdown A menu appears. Dropdown B menu never appears.
To Reproduce
Use sample code provided
Expected behavior
Menu A should appear when toggling Dropdown A, Menu B should appear when toggling Dropdown B
Screenshots
Versions:
Sample code
I replaced DropdownToggleButton with button in this example but it does not matter where the toggle method is called.
I tried assigning custom unique ids and names to each component too and nothing helped.
Same issue persists when first custom toggle button is swapped for DropdownToggleButton
When instead the second custom toggle button is swapped for DropdownToggleButton the issue no longer occurs.
Tried uploading code block but markdown completely messed it up, so here's screenshot:
GitHub repo
Can create one if needed
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: