Start with a reproducible failure
A modal needs a complete lifecycle: opening, a meaningful name, focus inside, dismissal and logical return. Darkening the background does not establish that journey.
Use a small controlled test to separate a symptom from its cause. Record the starting state, affected URL and observed outcome so that another person can repeat the check.
Collect evidence before changing anything
Open by keyboard from two different buttons. Follow Tab and Shift+Tab, then close with Escape and the visible button. Inspect the active element after each dismissal and after content changes.
Fictional example: A comparison page opens product details from several cards. On closing, focus jumps to the document start and the visitor loses the card they were investigating.
| Check | Expected outcome |
|---|---|
| Starting condition | Dismissal looks correct but the next Tab starts in the wrong place. |
| Implementation | Open by keyboard from two different buttons. Follow Tab and Shift+Tab, then close with Escape and the visible button. Inspect the active element after each dismissal and after content changes. |
| Verification | Each opener receives the correct return and dialog controls remain reachable without focus moving into the background. |
Fix the cause and repeat the test
Remember the actual opener on every opening. Restore focus there if it remains, otherwise choose a logical next step. Avoid a fixed reference to the first button.
Repeat the same test after the change and add a nearby case that already worked. One successful case establishes that task in those conditions; it does not certify the whole website.
What the test establishes
Each opener receives the correct return and dialog controls remain reachable without focus moving into the background.