The menu and the command must share one rule
If a UI shows a command as available, check it against the same rules the command will run with. Otherwise the menu offers actions that throw.
Read the lesson →A div posing as a button owns its keyboard
Replacing a <button> with a div to avoid nesting means you now own everything the button did for free: focus, Enter and Space, disabled state, and not swallowing events meant for the real buttons inside it.