Modal focus containment: six recorded examples
The downloads contain six original inputs, their expected labels and one recorded API observation per input revision. Disagreements stay visible.
Supply forward and backward keyboard observations for an open modal. Check whether focus stays inside, escapes to the background or lacks enough evidence for a conclusion.
This check concerns the interval while a modal is open. It is separate from selecting a destination for focus after closing, announcing the dialog, or deciding whether a particular interaction should be modal.
The inputs are synthetic behavior reports. Contained means the supplied observations support this narrow claim, not that the page has passed a browser or accessibility audit. Test the actual interface with a keyboard before relying on it.
This original code and behavior review adapts a review-only rule in the taste-lint repository linked by the source post. Synthetic inputs and labels are ours. Review-only source status does not establish an executed upstream check; this page does not run code or certify an application.

Use the sample to understand the rule, then test your own input for modal focus containment.

Supply forward and backward keyboard observations for an open modal.

Open the decision rules and keep the intended distinction between Contained, Escape, Nonmodal, Unclear. Edit the choices only when testing your own rule.

Use a sample first, then try your own input. Compare the selected label with the other returned probabilities.

Review Unclear before using a result. The label is a decision about the supplied information, not an executed action.
| Original input | Observed label | Leading probability |
|---|---|---|
| Both directions wrap | Contained | 99.0% |
| Forward escape | Escape | 88.0% |
| Backward escape | Escape | 99.0% |
| One direction unknown | Unclear | 85.0% |
| An explicit nonmodal panel | Nonmodal | 99.0% |
| Library name only | Unclear | 100% |
These are six original synthetic inputs, tested once per request revision. The percentage is the leading option probability, not measured accuracy. Authored expectations and any disagreements remain in the downloadable evidence. 6 of 6 results matched the authored fixture expectations.Verified
The downloads contain six original inputs, their expected labels and one recorded API observation per input revision. Disagreements stay visible.
The single-request SDK runner uses your private TYPESAFE_API_KEY. The offline consumer reads saved observations, checks request hashes and prints a pending output. It does not call the model or change any external system.
# Offline: inspect the downloaded saved observations. No API key is needed.
python preview_choice_workflow.py samples.json saved-api-results.json
# Optional live request: install the SDK and set TYPESAFE_API_KEY privately.
npm install @typesafe-ai/sdk@0.6.0
node run-choice-sample.mjs samples.json case-1
# The live response prints to the terminal; it does not update saved-api-results.json.The input contract and these limits define what the result means.
No. It identifies semantics, while containment concerns keyboard behavior. Supply the modality and both focus paths.
No. It evaluates focus while the modal remains open. Escape-key closure and the destination after closing need separate observations.
It describes the distribution over the supplied choices for this request. These six synthetic examples are functional tests with authored expectations, not a production accuracy benchmark.
No. The demo displays a label and distribution. The downloadable consumer produces a pending preview packet. Application code and a separate authorization policy would control any real action.
Edit the example above to see how a changed fact affects the decision, or open the Playground for another task.