The screenshot shows the native fixture open in Chrome 156. The blue focus ring is on Close and the backdrop dims the controls behind it.
The modal opens and the screenshot looks good. Then you press Escape. It stays open. Close it with the mouse and press Tab. You may no longer be where you started.
When Chrome released Modern Web Guidance 1.0, Paul Irish used dialogs to illustrate a gap between what browsers can do and what coding agents tend to implement. I built two small fixtures to see what an apparently working modal could miss. Chrome's release post · Original discussion
One entry point, two implementations, three checks
I opened both fixtures with Enter in Chrome 156 at 1280px. The first was a custom div with role="dialog" and aria-modal="true" that deliberately only toggled visibility. The second was a native <dialog> opened with showModal(). Both initially focused the Close button.
- Press Escape. The custom modal stayed open. The native modal closed and returned focus to Open settings.
- Try to focus the background. I called
focus()on a background button in both fixtures. It took focus in the custom example. Focus stayed inside the native dialog in the other. - Activate Close with the keyboard. Both closed. The custom example left focus away from the opener. The native one returned it to Open settings.
These observations apply to two fixtures I wrote for this comparison. A custom component with the necessary behavior can pass the same checks.
Give your coding agent the acceptance criteria
If the interaction calls for a modal, this example gives you a labelled dialog, a visible Close button, and a predictable entry point.
<button id="open-settings" type="button">Open settings</button>
<dialog id="settings" aria-labelledby="settings-title">
<h2 id="settings-title">Settings</h2>
<form method="dialog">
<button autofocus>Close</button>
</form>
</dialog>
<script>
const button = document.querySelector('#open-settings');
const dialog = document.querySelector('#settings');
button.addEventListener('click', () => dialog.showModal());
</script>Try putting this in the task you give your agent:
Open Settings with the keyboard and report where focus lands. While the dialog is open, verify that a background control cannot take focus. Close it with Escape and with the Close button in separate runs. Report whether focus returns to the opener. Include the browser, each action, and the actual results.
Test the visible Close button in your target mobile browsers. If the action removes the opener, such as deleting a list item, decide where focus should go next and add that case. Native behavior handles part of the interaction. Your product still sets the rules about what stays on the page. MDN's dialog reference · Boloop's acceptance checklist