Blazor: add returnValue to onclose event of <dialog>
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Is your feature request related to a problem? Please describe the problem.
_No response_
### Describe the solution you'd like
Add the returnValue of a `` to the onclose event. The `close` event of the HTMLDialogElement is just a generic `Event`, so an empty `EventArgs` seems right. But the returnValue gives the developer the information which button was pressed to close the dialog.
### Additional context
If you have a button like this
`Submit`
then the dialog will be closed and the content of `value` is placed into the `returnValue` property of the dialog. But you have to read it separately from this property, it is not part of the close event. When you are in C# you have to use JS Interop to get this value.
Before `` you usually need a dialog service and a container component somewhere in the body and some JavaScript and C# to wire everything together. Nowadays you can create and control the basic functionality of a dialog using HTML only. Opening and closing works with buttons and command/commandfor attributes. On the C# side it is mostly sufficient to subscribe to the already provided events `close` and `toggle`. When toggle is repaired (#66479) only the returnValue is missing to be able to skip JS interop at all.
Contributor guide
Assessment
This issue has not been assessed yet.