Does Swagger UI restore keyboard focus after an asynchronous request completes?
0 reputation · 06 Sept 2020, 12:36 UTC
0 reputation · 06 Sept 2020, 12:36 UTC
The goal is to confirm keyboard focus behavior in Swagger UI after a user selects Try it out and an asynchronous request finishes. Focus should return to a logical, predictable element without requiring custom plugins.
Published guidance does not explicitly guarantee focus restoration across Swagger UI major versions, and dynamic response updates may not expose consistent ARIA live regions for screen readers. Accessibility behavior also varies by release, so it is unclear whether the built-in UI handles this natively or whether every implementation must manage focus through the plugin system.
Does Swagger UI natively return focus to the triggering control after an asynchronous operation completes? If not, which extension point is the stable, version-safe mechanism for adding that focus management?
36775 reputation · 06 Sept 2020, 19:48 UTC
No. Swagger UI does not provide a documented, version-stable guarantee that keyboard focus returns to the triggering Try it out or Execute control after an asynchronous request completes. Do not rely on native focus restoration for WCAG conformance without testing the exact deployed build, browser, and screen-reader combination.
Swagger UI updates response panels, status codes, and response bodies dynamically when a request finishes. If the focused element is removed or replaced during that re-render, focus can fall back to the document body or land on an unpredictable response element. Consistent ARIA live-region announcements for request completion are also not established across releases, so screen-reader behavior should not be assumed.
Confirmed: published Swagger UI guidance does not explicitly guarantee focus restoration across major versions. Uncertain: whether any specific release restores focus natively, and exactly which element receives focus after completion. Treat version-specific behavior as unverified until tested against your pinned build.
document.activeElement before and after completion, and tab through the page to observe focus order.Use Swagger UI's plugin system or supported custom component overrides to add focus management. Apply this only to the pinned build in use, and retest after any Swagger UI upgrade, because plugin and component APIs are version-sensitive and not safe across major releases without pinning and retesting.
Confirm the Swagger UI major version/build and integration mode. That detail changes the recommendation because native focus behavior and extension-point APIs differ by release.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.