import "./App.css"; import { useState } from "react"; function App() { const [closeReturnValue, setCloseReturnValue] = useState(""); const [requestCloseReturnValue, setRequestCloseReturnValue] = useState(""); const [blockRequestClose, setBlockRequestClose] = useState(false); const [requestCloseLog, setRequestCloseLog] = useState([]); const [customCommand, setCustomCommand] = useState(""); function logRequestClose(message) { setRequestCloseLog((prev) => [...prev.slice(-4), message]); } return (
Buttons use commandFor to target an element by id and{" "}
command to run a built-in or custom action.
Target: #demo-popover (popover="auto")
Popover content
Opens #dialog-show-modal as a modal (
HTMLDialogElement.showModal()).
Closes immediately (HTMLDialogElement.close()). With{" "}
value on the button, that string becomes the dialog's{" "}
returnValue.
Last returnValue:{" "}
{closeReturnValue || "(none yet)"}
Fires cancel then close (
HTMLDialogElement.requestClose()). Call{" "}
preventDefault() on cancel to keep the dialog
open.
Last returnValue:{" "}
{requestCloseReturnValue || "(none yet)"}
Names starting with -- are author-defined. The target
receives a command event; handle it in{" "}
onCommand (no browser default behavior).
Command target
Last event.command:{" "}
{customCommand || "(none yet)"}