serenity
serenity copied to clipboard
LibWeb: Add support for opening and closing non-modal dialog elements
This PR fleshes out HTMLDialogElement::show()
and HTMLDialogElement::close()
, which were previously stubbed out. Support for submission of forms with the "dialog" method has also been added.
Note: The parts of these methods I have left unimplemented deal with non-modal dialogs, which we don't yet support.
Demo with this test page:
<!DOCTYPE html>
<body>
<dialog id="test-dialog" open>
<form method="dialog">
<button>Close</button>
</form>
</dialog>
<button id="show-button" onClick="show()" hidden>Show</button>
</body>
<script>
const dialogElement = document.getElementById("test-dialog");
const showButton = document.getElementById("show-button");
dialogElement.addEventListener("close", (event) => {
showButton.hidden = false;
});
function show() {
dialogElement.show();
showButton.hidden = true;
}
</script>
https://github.com/SerenityOS/serenity/assets/2817754/68b20d95-56aa-42fb-8400-943180594f77
Thanks for the very helpful review! I've updated the PR to fix the issues you highlighted.