command and commandfor attributes were recently added to the HTML spec, along with a new command event. This is supported in Chrome/Edge since version 135, Firefox 144 and Safari 26.2. See MDN for a list of the valid commands - the command event should fire for all these commands.
React version: 19
Steps To Reproduce
- Include the following markup
<button command="toggle-popover" commandfor="popover">Toggle popover</button>
<div onCommand={handleCommand} popover="auto" id="popover">popover content</div>
- Define the handleCommand function
function handleCommand(event) {
console.log(`a command happened: ${event.command}`);
}
- Open in Chrome or Edge and look at the browser dev tools console.
Link to code example: https://codesandbox.io/p/sandbox/distracted-lucy-vlh25y
The current behavior
Errors with the message: "Unknown event handler property onCommand. It will be ignored."
The expected behavior
The command event triggers the event handler.
commandandcommandforattributes were recently added to the HTML spec, along with a newcommandevent. This is supported in Chrome/Edge since version 135, Firefox 144 and Safari 26.2. See MDN for a list of the valid commands - thecommandevent should fire for all these commands.React version: 19
Steps To Reproduce
Link to code example: https://codesandbox.io/p/sandbox/distracted-lucy-vlh25y
The current behavior
Errors with the message: "Unknown event handler property
onCommand. It will be ignored."The expected behavior
The
commandevent triggers the event handler.