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

Closing modal using ModalReference #143

Merged
merged 7 commits into from
Apr 2, 2020
Merged

Closing modal using ModalReference #143

merged 7 commits into from
Apr 2, 2020

Conversation

larsk2009
Copy link
Collaborator

This PR closes #120. It adds a Close() function to ModalReference. Optionally a ModalResult can be passed, which I think is handy when having a long-running task that can give some result.

I added an example that shows the loading dialog while waiting for 5 seconds, as I think this is what people were trying to make in #120.

I added a new function to the ModalService that can close a modal using the ModalReference instead of the ModalReference.Id. The reasoning for this function is because I wanted to keep the arguments used between the OnModalInstanceAdded and OnModalCloseRequested the same in the ModalService. I can understand though if we would rather just use the functions that use the ModalReference.Id. Just let me know!

Copy link
Member

@chrissainty chrissainty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this work is awesome @larsk2009! 🎉

I've made a few suggestions around keeping details encapsulated. I think it would be best to have developers only work with the ModalReference and not expose internal details (Close methods) to the outside world.

Also, I noticed you only added the example to the Blazor Server example and not to the Blazor WebAssembly one. If you could add it to both that would be great.

Looking forward to hearing your thoughts.

src/Blazored.Modal/ModalReference.cs Outdated Show resolved Hide resolved
src/Blazored.Modal/ModalReference.cs Outdated Show resolved Hide resolved
src/Blazored.Modal/ModalReference.cs Outdated Show resolved Hide resolved
src/Blazored.Modal/ModalReference.cs Outdated Show resolved Hide resolved
Comment on lines 79 to 91

/// <summary>
/// Closes the <paramref name="modal"/>
/// </summary>
/// <param name="modal">The <paramref name="modal"/> of the modal to close.</param>
void Close(ModalReference modal);

/// <summary>
/// Closes the <paramref name="modal"/>
/// </summary>
/// <param name="modal">The <paramref name="modal"/> of the modal to close.</param>
/// <param name="result">The result of the modal</param>
void Close(ModalReference modal, ModalResult result);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should add these methods to the interface, I think it would be better to keep developers working with the ModalReference only. What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with your point here. The reason I added it to the interface is because than the ModalReference can use the interface and doesn't depend on the implementation. But looking at it again, I think there will probably not be another implementation of this interface so than I think it is better to do what you suggested.

src/Blazored.Modal/Services/ModalService.cs Outdated Show resolved Hide resolved
src/Blazored.Modal/Services/ModalService.cs Outdated Show resolved Hide resolved
@larsk2009
Copy link
Collaborator Author

@chrissainty I forgot to add the example to webassembly. Thanks for reminding me.

Copy link
Member

@chrissainty chrissainty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work!! 👏

@chrissainty chrissainty added the Feature New feature that will be added to the project label Mar 30, 2020
@chrissainty
Copy link
Member

@larsk2009 I've just realised, could you add a new page to the docs site for this feature? If you can't for any reason I can add a new issue to do it separately. But it would be great to get it all in together.

@larsk2009
Copy link
Collaborator Author

I added the docs. First time using docFx so please let me know if it looks good.

@chrissainty
Copy link
Member

The DocFX stuff looks great @larsk2009. I think we're ready to merge! 🥳

Thank you so much for this work.

@chrissainty chrissainty merged commit 4cb6c34 into Blazored:master Apr 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature that will be added to the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Force the closure
2 participants