Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Part of #1461
This PR is a proof of concept of what could be a new component to render native
dialog
elements.It covers the basic functionality, with an
open
prop that triggers thedialog.show()
side effect when true, ordialog.close()
when false.It also takes into consideration how regular dialogs and modal dialogs should be displayed.
Finally, it does not make assumptions about how children should be rendered, rendering what's provided verbatim.
For cases where we want to render the dialog as a panel/card, we can consider adding a new component that wraps children in a panel and then nests that into the new dialog.
Open questions
modal
prop for modal sizes, because it was convenient, and the resulting API seems intuitive:modal
for an auto-size modal dialog, andmodal="lg"
for a large-size modal dialog.Should we have a
size
prop that can be used with non-modal dialogs as well? Should we have a separateModalDialog
that handles sizes?dialog
elements? Perhaps we could define a component wrapping the new dialog and the old one and orchestrating which one to render based on browser support.closeOnFocusAway
prop? It is false by default and is not being redefined in any downstream project.Also, you cannot focus away when opening the native dialog as modal, and when it is not a modal you will likely want to keep it open.
closeOnEscape
? It is true by default for modal dialogs and false for regular dialogs.Native dialogs implement this natively when opened as modal, which matches that behavior.
There's only one use case in which we are currently using a non-modal dialog which can be closed with
Esc
, which is the grade comment popover. In this case we are using the dialog because it's convenient, but it is actually implementing the popover pattern, which is different.closeOnClickAway
? It's false by default and like in previous point, we are redefining this behavior only for the grade comment popover.TODO
closeOnClickAway
, and implement it if socloseOnFocusAway
, and implement it if socloseOnEscape
, and implement it if soinitialFocus
restoreFocus
transitionComponent