Hello all,
i have a button that toggle a boolean Visible property binded to the IsOpen on the SfSidebar.
It work as expected but if i close the sidebar by clicking on the outside of it, when i click again the button it not work the first time. When clicked the second time it works.
Can you help me with this issues?
<SfButton CssClass="btn-Sidebar" OnClick="Toggle"> <i class="fas fa-2x fa-project-diagram text-white menuIcon"></i> </SfButton>
private void Toggle() { IsVisible = !IsVisible; }
<SfSidebar ID="samplingSideBar" Width="280px" Type="SidebarType.Over" @bind-IsOpen="IsVisible" Target="#mainBody" CloseOnDocumentClick="true" > <ChildContent> ....... </ChildContent> </SfSidebar>
Hello!
i tested your project without doing any modification and the sidebar do exactly the same wrong behavior i have seen in my project.
I have attached a video of the bug using your project.
please let me know if you need further information.
thank you very much
best regards
=
<SfSidebar ID="samplingSideBar" @ref="sidebarObj" Width="280px" Type="SidebarType.Over" OnClose="close" @bind-IsOpen="IsVisible" Target="#mainBody" CloseOnDocumentClick="true">
</SfSidebar>
<div id="mainBody" class="text-content" style="text-align: center;height:560px">
<div>Main content</div>
<div>
<SfButton CssClass="btn-Sidebar" OnClick="Toggle">Sidebar open
</SfButton>
</div>
</div>
</div>
@code{
SfSidebar sidebarObj;
public bool IsVisible { get; set; } = false;
public void Toggle()
{
IsVisible = true;
}
} |
Hello and thanks for the answer.
Just for asking... is it not possible to keep both solutions at the same time?
I mean: open a sidebar via a button and close it either with the same button with which I opened it or by clicking outside the sidebar itself.
At the moment if I try to configure the sidebar like this, it doesn't work properly.
<SfSidebar Type="SidebarType.Over" @bind-IsOpen="IsVisible" Target="#mainBody" CloseOnDocumentClick="true">
</SfSidebar>
<div id="mainBody" class="text-content" style="text-align: center;height:560px">
<div>
<SfButton @onmousedown="Check" OnClick="Toggle">Toggle</SfButton>
</div>
@code{
SfSidebar sidebarObj;
public bool IsVisible { get; set; } = false;
bool isRestrict { get; set; } = false;
private void Check()
{
isRestrict = IsVisible;
}
public void Toggle()
{
if (!IsVisible && !isRestrict)
{
IsVisible = true;
}
else
{
isRestrict = false;
}
}
}
|
Thanks for the suggestion, in that way work perfectly.
thank you very much
Maurizio