# 5730 MINInvoker Modal
# 57
30 MIN
Overview
Not every interaction needs React state. The browser can open and close a <dialog> with plain HTML attributes via the Invoker Commands API — no useState, no event handlers, no JavaScript.
Requirements
- Use the Invoker Commands API to wire the "Contact Us" button (
data-testid="open-dialog") so it opens the dialog when clicked — withoutuseState, refs, or manual DOM calls. - Wire the "Close" button (
data-testid="close-dialog") so it closes the dialog when clicked. - The dialog must be closed initially.
- The dialog already contains a form with name, email, message fields, and a submit button. Do not remove or rename any of these elements or their
data-testidattributes. - The
declare module "react"block at the top ofApp.tsxmust not be removed or modified — it already provides the TypeScript types you need.
Notes
- Check the Invoker Commands API on MDN. The idea: a
<button>usescommandandcommandforattributes to tell the browser to callshowModal()orclose()on a target element — no JavaScript event handlers. - To link a button to the dialog: give the dialog an
id, then setcommandforon the button to that same id. Usecommand="show-modal"to open andcommand="close"to close. useId()from React is the idiomatic way to generate a unique id, but any unique string works.- The
declare module "react"block is a TypeScript module augmentation. It addscommandandcommandfortoButtonHTMLAttributesso you can use them in JSX without type errors. - The
data-testidattributes on the button, dialog, and form fields are required by the tests — do not rename or remove them.
Tests
- renders the app title
- renders the open button with command attributes
- matches the button commandfor with the dialog id
- dialog does not have the open attribute initially
- close button has command close with matching commandfor