Skip to content
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

Add Clicked event on toggle components #2043

Closed
Smurf-IV opened this issue Mar 16, 2021 · 2 comments
Closed

Add Clicked event on toggle components #2043

Smurf-IV opened this issue Mar 16, 2021 · 2 comments
Labels
Type: Feature ⚙ Request or idea for a new feature.
Milestone

Comments

@Smurf-IV
Copy link

Is your feature request related to a problem? Please describe.
I want to performa an action when a sidebar DropDownToggle item is clicked

Describe the solution you'd like

<BarDropdown>
    <BarDropdownToggle Clicked="@((visible) => LoadMarkup(visible, markUp))">
        <BarIcon IconName="FontAwesomeIcons.CropAlt" Style="font-size: 1rem;" />&nbsp;@markUp.Name
    </BarDropdownToggle>

Additional context

I have tried both of the following and they are not called !

@inherits Blazorise.BarDropdownToggle
@code {
    [Parameter]
    public EventCallback Clicked { get; set; }

    //protected new Task ClickHandler()
    //{
    //    Console.WriteLine(@"ClickHandler - IN");
    //    Clicked.InvokeAsync((object)null);
    //    return base.ClickHandler();
    //}

    protected override void HandleVisibilityStyles(bool visible)
    {
        Console.WriteLine(@"HandleVisibilityStyles - IN: {0}", visible);
        if (visible)
            Clicked.InvokeAsync((object)null);
        base.HandleVisibilityStyles(visible);
    }
}
@Smurf-IV
Copy link
Author

FYI:
I have managed to do it this way:

//@*https://github.com/stsrki/Blazorise/issues/2043*@
using System;
using Microsoft.AspNetCore.Components;

namespace LR.Ocelot.Client_Web.ClientWeb.Shared.Components
{
    public class BarDropdownToggleClick : Blazorise.BarDropdownToggle
    {
        [Parameter] public EventCallback Clicked { get; set; }

        protected override void HandleVisibilityStyles(bool visible)
        {
            Console.WriteLine(@"HandleVisibilityStyles - IN: {0}", visible);
            base.HandleVisibilityStyles(visible);
            if (visible || ParentDropdownState.Visible)
                _ = Clicked.InvokeAsync((object)null);
        }
    }
}

Notice the inclusion of the ParentDropdownState.Visible

@stsrki
Copy link
Collaborator

stsrki commented Mar 16, 2021

It's a hack but as long as it works I guess it's OK. In the meantime, I can add it for the next release.

@stsrki stsrki added the Type: Feature ⚙ Request or idea for a new feature. label Mar 16, 2021
@stsrki stsrki added this to the 0.9.4 milestone Mar 16, 2021
@stsrki stsrki changed the title BarDropdownToggle - Can there be a Clicked handler added Add Clicked event on toggle components Apr 15, 2021
@stsrki stsrki mentioned this issue Apr 15, 2021
@stsrki stsrki closed this as completed Apr 15, 2021
@stsrki stsrki moved this to ✔ Done in Development Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature ⚙ Request or idea for a new feature.
Projects
Archived in project
Development

No branches or pull requests

2 participants