All practice tasks

Coding (Platform)

Fallback target resolution

express · Easy · fallback policy

A production API needs a fallback target resolution repair at its service boundary. A React dialog can close because the user confirms, cancels, presses Escape, or the trigger disappears after navigation. The current reducer always restores focus to the original trigger, including when it is no longer mounted.

Task

Implement the fallback target resolution contract used by the supplied HTTP adapter. Choose one safe focus target from the close reason and the currently mounted element IDs.

Contract

Input is {triggerId,fallbackId,closeReason,mountedIds}. Return {focusId,announce}. Prefer a mounted trigger, then a mounted fallback, otherwise null.

Acceptance criteria

  • Never return an unmounted element.
  • Use the same target for confirm, cancel and Escape.
  • Return a concise close announcement.
  • Do not make focus depend on object identity.
  • Return a deterministic JSON-serializable result for the HTTP adapter.

Constraints

  • Do not mutate caller-owned input.
  • Keep the supplied framework adapter and public contract unchanged.
  • Add candidate tests for at least one boundary not covered by the public cases.

Editable files

  • src/repair.js — Task-specific state or service boundary
  • tests/candidate.test.js — Candidate-authored regression

What this task practices

Fallback target resolution is a coding (platform) interview exercise that trains prompt interpretation, explicit assumptions, a concrete response, and a clear explanation of tradeoffs. The catalog marks it as easy difficulty. It focuses on State Modeling, Regression Testing, Technical Reasoning. The signed-in workspace provides the tools for the round and evaluates the attempt against task-specific criteria. Reference solutions, hidden checks, evaluator instructions, and candidate work remain private.

Sign in to startThe workspace and evaluation open after sign in.