Kukks / Blazor.Ionic

Integration of Ionic5 into Blazor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can `OnClick` become `@onclick`?

DanGould opened this issue · comments

In the demo I see you're using OnClick on IonButton for example. Can the EventHandler from @onclick serve that purpose so that there is one standard interface? What would need to change?

OnClick adds some additional functionality, notably navigating internally when a relative href attribute is provided:

 protected bool ShouldInterceptHref => InputAttributes != null && (InputAttributes.ContainsKey("href") &&
                                                                          (!InputAttributes.TryGetValue("target",
                                                                               out var target) ||
                                                                           target.ToString().ToLowerInvariant()
                                                                               .TrimStart('_') == "self"));

        protected async Task OnClickCallback(MouseEventArgs obj)
        {
            if (ShouldInterceptHref)
            {
                NavigationManager.NavigateTo(InputAttributes["href"].ToString());
            }
            else
            {
                await OnClick.InvokeAsync(obj);
            }
        }

You don't need to use it, but I would advise against it to avoid glitches