Giter Club home page Giter Club logo

Comments (8)

henon avatar henon commented on June 16, 2024 1

We just make OnClick obsolete with a message to use VisibleChanged instead. After it has been obsoleted for a time we can remove it in a future major version.

from mudblazor.

danielchalmers avatar danielchalmers commented on June 16, 2024

I'm planning to replace all other usages of OnClick with the VisibleChanged event like I did in #8914 in order to avoid subtle bugs. How do we stop people from falling into this same anti-pattern without removing OnClick entirely? @henon @ScarletKuro

from mudblazor.

danielchalmers avatar danielchalmers commented on June 16, 2024

@henon

/// <summary>
/// Triggers an event callback when the overlay is clicked.
/// </summary>
[Parameter]
[Obsolete("Use VisibleChanged with AutoClose to handle the overlay disappearing in a universal way.")]
public EventCallback<MouseEventArgs> OnClick { get; set; }

Can we make AutoClose true by default? It seems like that's the only way it's actually used in the whole library so it would make sense if we made that switch while moving away from OnClick. The pattern is always "OnClick = make visible false".

from mudblazor.

henon avatar henon commented on June 16, 2024

OK, we can change AutoClose to true by default. Maybe we should think if obsoleting OnClick is even necessary. What if someone wants to use AutoClose="false" and doesn't want to close on click but still get the click event to do something, i.e. show a message or whatever? Once we remove it that wouldn't be possible any longer.

As for prevending people to use OnClick instead of AutoClose we can also just show a warning box in the docs.

from mudblazor.

henon avatar henon commented on June 16, 2024

Or maybe we add an OnClosing eventcallback with class CloseEventArgs which contain a writable property bool Cancel which the user can use to prevent or allow the overlay from closing based on their business logic? In the overlay we await the OnClosing eventcallback and based on the value of Cancel update Visible accordingly?

WPF has such logic, would this be ok for Blazor as well @ScarletKuro ?

from mudblazor.

danielchalmers avatar danielchalmers commented on June 16, 2024

ping @ScarletKuro

from mudblazor.

danielchalmers avatar danielchalmers commented on June 16, 2024

I'm going to put this on hold due to the potential for issues to pop up and some components (MudDrawer) really need further refactoring which will take more time.

from mudblazor.

ScarletKuro avatar ScarletKuro commented on June 16, 2024

WPF has such logic, would this be ok for Blazor as well @ScarletKuro ?

Yeah

from mudblazor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.