-
Notifications
You must be signed in to change notification settings - Fork 409
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
feat: allows showing a dialog by only providing a RenderFragment. #1496
feat: allows showing a dialog by only providing a RenderFragment. #1496
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also make sure the existing Unit Tests validate and try to add a coule of new ones
src/Core/Components/Dialog/ContentComponents/RenderFragmentDialog.razor
Outdated
Show resolved
Hide resolved
Could you give us some examples of where this might be an interesting situation?
I'm not against accepting these problems, but to solve what problems? |
…mussen/fluentui-blazor into render-fragment-dialog
@dvoituron - I can see why you might be hesitant. I generally agree with your argument here regarding razor markup in C#, and if everyone followed the pattern of always having a separate C# code file for their components then this would hold true. However, there are people that include their C# in the razor file itself, especially for smaller components. My main reason for this is that I find there are several instances where I want to collect a single input from the user, but find creating an entire component a bit heavy-handed. This is where I see this scenario more compelling. I have used the following in my own code (I currently have this as an extension method of the private async Task RejectCarShowRegistration(CarShowRegistration carShowRegistration)
{
var rejectionReason = string.Empty;
// This is where creating an entire component, just to get a single piece of information is a bit of overkill.
var dialogInstance = await this.DialogService.ShowDialogAsync(
@<div style="width: 100%;">
<FluentTextArea @bind-Value=rejectionReason Style="width: 100%" />
</div>
, new DialogParameters
{
Title = "Rejection Reason",
PrimaryAction = "Reject",
PreventDismissOnOverlayClick = true,
});
var result = await dialogInstance.Result;
if (!result.Cancelled)
{
await this.PerformOperationSafely(async () =>
{
// do something with the 'rejectionReason' here
}
} Anyway, I appreciate your consideration in adding this to the project... I feel that others can find this feature useful as well. Let me know if you need anything else to complete this PR. |
@StevenRasmussen I understand your request, but it doesn't answer my two questions :-)
The biggest problem for me is that we're going to present a way of developing that doesn't seem ideal to me, when it would be possible to achieve the same result without too much extra work. Am I wrong? |
@dvoituron - To answer your questions:
Certainly this could be a solution. I'm not contending that everything should be done using this new approach. I guess it comes down to a matter of opinion (which is often the case with different approaches to coding 😉). For me personally, I would not want to create a component that serves many different purposes, just for the sake of having a component that could be used for the
In the instance where a In the end it's going to come down to your opinion of whether you find this could be useful for other developers or not. I don't think that one approach is "correct" and one is "wrong" (I use both in my codebase). I think it's a matter of choosing the right tool and approach for each scenario. This feature naturally targets very simple dialogs, ones that collect 1 or 2 pieces of data from a user or perhaps just displays some simple text in a custom format. In my opinion it is perfectly fine (and even preferred) to inline the dialog code right into the method that is invoking it instead of creating another file for something that is so simple and will only ever be used in this very specific instance. Anyway, I really appreciate all the effort that your team has put into this library... just thought that I'd add something to it that I find really useful and that I think other developers will appreciate too. |
Indeed, we could add this way of displaying DialogBoxes, perhaps some developers like to work this way (especially since Blazor allows it) :-) I'll just add a comment for this new method, pointing out that this parameter is not possible / useful. |
Pull Request
📖 Description
Sometimes it is helpful not to have to create a full-blown component to render as a dialog. This PR allows supplying just a
RenderFragment
to be displayed as a dialog.👩💻 Reviewer Notes
You can see how this works by reviewing the demo site for dialogs. I have added a new section at the bottom that demonstrates the new functionality.
✅ Checklist
General
Component-specific