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

[Feature Request] Add OnBeforeClose hook. #540

Open
MarcelRoozekrans opened this issue Nov 15, 2023 · 4 comments · May be fixed by #541
Open

[Feature Request] Add OnBeforeClose hook. #540

MarcelRoozekrans opened this issue Nov 15, 2023 · 4 comments · May be fixed by #541
Labels
Feature Request Request to add a new feature Needs: More Information The author needs to provide more information on the issue.

Comments

@MarcelRoozekrans
Copy link

Is your feature request related to a problem? Please describe.
We have an application where we want to execute code at then end of the dialog. The logic that now closes first the dialog and adfter that we can execute some custom logic.

Describe the solution you'd like
A OnBeforeClosing hook so we can execute code that runs behind the opened dialog.

Describe alternatives you've considered
There are none I can think of.

Additional context
I'll open a PR that implements this feature.

@MarcelRoozekrans MarcelRoozekrans added Feature Request Request to add a new feature Triage Issue needs to be triaged labels Nov 15, 2023
MarcelRoozekrans added a commit to MarcelRoozekrans/Modal that referenced this issue Nov 15, 2023
@MarcelRoozekrans MarcelRoozekrans linked a pull request Nov 15, 2023 that will close this issue
@chrissainty
Copy link
Member

Hey @MarcelRoozekrans, thanks for your request. I'm just trying to understand the use case. When opening a modal it looks something like this:

var moviesModal = Modal.Show<Movies>("My Movies");
var result = await moviesModal.Result;

if (result.Cancelled)
{
    Console.WriteLine("Modal was cancelled");
}
else if (result.Confirmed)
{
    Console.WriteLine("Modal was closed");
}

What benefit would a OnBeforeClosing hook give versus just putting code that needs to run after the modal closes somewhere after the line that awaits the modal result?

@chrissainty chrissainty added Needs: More Information The author needs to provide more information on the issue. and removed Triage Issue needs to be triaged labels Feb 19, 2024
@MarcelRoozekrans
Copy link
Author

Hi @chrissainty, Thanks for the response !

This proposed solution is that you can execute an action before the dialog is closed. With your example above the dialog is closed first and the afterwards de logic is executed.

We need this because when the modal is closed I want to directly update the parent page. The actions we do in de OnBeforeClose take significant amount of time and there for the parent page has a ugly redraw with the new state way after the dialog is closed.

@oliv0533
Copy link

oliv0533 commented Apr 4, 2024

I'm in full support for this feature, with a small addition.

I'm currently working on an application where we need to show a "Are you sure you want to close this"-modal in case any changes has been made inside a that has been commanded to close. Currently we have to disable closing this modal by the x in the top or clicking outside. Then we add our own close button to the modal window and trigger the "Are you sure" modal using that button.

We would love to allow the the user to close the modal by clicking outside, but to do that we need this hook to run our own modal code first.

The addition we would love is the ability to stop the closing of the modal using this hook. Maybe this hook could return a bool or something, that could stop the closing process, so any changes inside the modal isn't disposed of.

@sskieller
Copy link

@chrissainty Is it a possibility we can help with this issue and get it prioritized? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Request to add a new feature Needs: More Information The author needs to provide more information on the issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants