<SfDropDownList CssClass="custom_class" TValue="string" TItem="Games" Placeholder="Select a game" DataSource="@LocalData">
<DropDownListFieldSettings Value="ID" Text="Text"></DropDownListFieldSettings>
</SfDropDownList>
public async Task Close(Syncfusion.Blazor.Navigations.EventArgs args)
{
// check the clicked target is dropdownlist or not using JS interop
var dropdownList_element = await JSRuntime.InvokeAsync<int>("Sidebar");
if (dropdownList_element == 0)
{
// If the elmeent is dropdownlist. cancel the close event.
args.Cancel = true;
}
else
{
args.Cancel = false;
}
}
Index.html
<script>
function Sidebar() {
if (document.activeElement.classList.contains("custom_class")) {
var index = 0;
}
else {
var index = 1;
}
return index;
}
</script> |
UG Documentation |
|
Demo link |
|
API reference |
https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor~Syncfusion.Blazor.Navigations.SfSidebar.html
|
Surely this is a bug with the way that the sidebar works and needs to be fixed rather than people having to add this hack?
Can you please demonstrate how to achieve this same result when using a MudSelect instead of an SfDropDownList ?
Hi Ben,
The CloseonDocumentClick property is used to collapse the Sidebar when you perform click on the Main content area. The Dropdown List popup element directly renders within the DOM body due to this Sidebar getting collapsed when you perform a click within the popup.
However, this collapse action doesn't trigger on other components that are directly rendered within the Sidebar instead of the body. So to avoid this specific popup-related issue, we suggest you cancel the Sidebar collapsing. You can avoid similar popup openings just by mentioning the common "popup" class name within the Close event.
Regards,
Indhumathy L
Yes I am trying to prevent the close when using a MudSelect inside the Sidebar. I am not using the SfDropDownList.
The above example does not seem to work for the MudSelect.
Ben, are you able to get the document.activeElement within the index.html file through an interop call? Share with us the exact element you are getting while performing MudSelect. Based on the shared details, we will further validate them at our end.
The above demonstartion zip file does not work if you upgrade to the latest version of the Syncfusion Sidebar. There is no longer a this.SideBarRight.Toggle() method on the Sidebar.
Ben, Based on your requirements, we have prepared and included the Sidebar sample in the latest version. Our previously attached sample was in the old version (18.2.56), and we have updated some of properties, methods and events in the Sidebar component from that old version.
Refer the below links to know more about our Blazor Sidebar component.
Demo : https://blazor.syncfusion.com/demos/sidebar/default-functionalities/
Documentation : https://blazor.syncfusion.com/documentation/sidebar/getting-started
API : https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.SfSidebar.html
Also, Check out the sample and get back to us if you need any further assistance.