imbahub
Menu +
EN
Talk to us
IMBAHUB / Knowledge & guides

The dialog closes but keyboard focus disappears

Dismissal looks correct but the next Tab starts in the wrong place.

The dialog closes but keyboard focus disappears
  1. Starting condition

    A modal needs a complete lifecycle: opening, a meaningful name, focus inside, dismissal and logical return. Darkening the background does not establish that journey.

  2. 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.

  3. Verification

    Each opener receives the correct return and dialog controls remain reachable without focus moving into the background.

  4. Decision

    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.

Each opener receives the correct return and dialog controls remain reachable without focus moving into the background.

Which check determines the next step?

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.

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.

CheckExpected outcome
Starting conditionDismissal looks correct but the next Tab starts in the wrong place.
ImplementationOpen 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.
VerificationEach 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.

Sources and further reading

Questions, answered

Is passing an automated test enough?

Combine technical checks with the actual visitor task. Document the environment, conditions and remaining limitations.

Which check determines the next step?

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.

IMBAHUB

What would you like to make possible?

Describe the website task and the failure or development requirement you want to scope.

Talk to us
Product interface set to English in an isolated environment with fictional English demo content.

Product interface set to English in an isolated environment with fictional English demo content.