frontend-patterns/research/candidates/FocusReturn.md

106 lines
5.8 KiB
Markdown
Raw Normal View History

---
title: Focus Return
status: draft
maturity: hypothesis
families: [quality, affordance]
scales: [L6]
admission: research-candidate-only
---
# Focus Return
Context: a modal task temporarily interrupts another keyboard workflow. Closing it
can leave users without a meaningful continuation point. Continuity competes with
changing document structure and the next task's needs.
Proposed solution: retain the invocation context and choose a meaningful focus
location inside the modal. On closing, return focus to the invoker when appropriate;
if it disappeared or completion changes the next step, choose a logical surviving
target. Define ownership for nested dialogs so an obsolete close callback cannot
move focus out of the current task.
Result: interruption has an explicit return path, but dynamic targets need lifecycle
handling. Do not steal focus on unrelated background updates or apply modal focus
containment to ordinary page regions. This narrow candidate does not claim complete
accessibility conformance; labeling, inert background and keyboard behavior remain
part of the containing dialog contract.
Evidence: B06 locates APG's modal focus guidance and return exceptions. Generalizing
to route transitions requires separate evidence. Alternative: inline interaction
when modal interruption adds no value. Defer merging this into a broader accessible
interaction pattern until contrasting cases support that scope.
Proposed relation: can support [Explicit Reconciliation](ExplicitReconciliation.md)
when comparison uses a modal; reconciliation does not require a modal.
Next test: close nested dialogs, delete the invoking row, and complete a task that
creates the next target; verify keyboard and assistive-technology behavior.
Evidence locators: [breadth review](../reviews/PatternBreadthExpansion.md).
All relations are research proposals; no canonical identity or admitted graph edges.
The next test is planned, not executed. Known uses of the complete proposed contract
have not been verified in this investigation.
## Executed partial evidence — 2026-09-26
[Boundary experiment](../reviews/BoundaryRecoveryExperiment.md) X05–X08 runs Radix
Dialog 1.1.23. Ordinary return succeeds; removal of the trigger leaves BODY focused
unless the application supplies a surviving target. Nested dismissal is timing-sensitive:
immediate Escape failed the parent-return obligation in the final recorded immediate
run, while a 100 ms settling variant passed. Neither focus arrival nor dialog visibility
alone proves dismissal ownership has stabilized. The delay is an experimental variable,
not a recommended fix. Root cause and accessibility conformance remain unverified;
retain hypothesis maturity and test lifecycle ownership before a stronger claim.
## Nested ownership isolation — 2026-09-26
[Follow-up matrix](../reviews/NestedDismissalIsolation.md) captures an interval where
the inner layer is registered and focused but the outer Escape listener still handles
input. This explains the recorded wrong-owner dismissal in the instrumented fixture.
Development/production and Chromium/Firefox comparisons retain all 48 trial results.
A current-owner guard can lose the keypress; private listener-readiness waiting passes
its trials but is not a product solution. Test ownership of dismissal as well as return
focus, including activation/teardown input. No arbitrary-delay fix, production repair
or full-pattern promotion is established.
## Experimental routing evidence — 2026-09-26
[Routing comparison](../reviews/NestedOwnershipRouting.md) tests layout registration,
a single document Escape dispatcher and event-time owner selection. The experimental
router meets 24/24 scenario assertions across two browsers/builds; its unmodified
control meets 20/24. It preserves cancellation and removes ownership on teardown
without a delay or private-readiness wait. Return to a replacement target still
requires application policy. This supports separating input ownership from focus
restoration, not a general production-ready fix: animated exits, competing owners,
rapid input bursts and assistive technology remain untested. Sixteen hypotheses;
no new pattern or maturity promotion.
## Boundary with route continuation — 2026-09-27
[Navigation focus contrast](../reviews/NavigationFocusExperiment.md) NF02–NF06
provides a non-modal counter-context: a successful route may continue at a new heading,
while failed navigation keeps the invoker and background work leaves focus alone.
A held response must respect focus moved to a surviving search field. Raw htmx in
this fixture restores a same-ID link; that behavior alone does not choose the next
task. Preserve this candidate's modal scope instead of treating every route change
as a return-to-invoker problem. No general route-focus pattern or AT validation is
admitted; delayed history restoration and competing navigation remain open.
## Completion ownership contrast — 2026-09-27
[NO01–NO06](../reviews/NavigationOwnershipExperiment.md) strengthen the route/modal
scope boundary. A still-current history result can restore content without taking
focus from a newer search task; an obsolete navigation result must not supply a
continuation at all. The earlier single-response route policy is insufficient for
competing completions. This contrast does not expand the modal candidate into a
universal routing pattern or prove AT behavior.
## Independent non-modal source contrast — 2026-09-27
[Zulip ZN05–ZN07](../reviews/ZulipNavigationSourceStudy.md) locates search entry/exit
focus policy and selection-aware editing restoration. These are task-specific
continuations, not evidence of returning from a modal to its invoker. The inspected
editing restoration schedules focus work after a selected-message check; this does
not prove ownership is valid when the timer runs. Retain the modal scope and mark
AT/runtime validation and auxiliary continuation behavior unknown.