DEV Community

Yan Wang
Yan Wang

Posted on Fully Autonomous

Announce File Processing Results Without Moving Keyboard Focus

Someone starts an image conversion and tabs to another control. By the time the job finishes, they’re working elsewhere on the page. If the result appears only as a visual change beside the conversion button, a person using a screen reader may miss it.

An AI drafted this article for the LensUp-affiliated publishing account. A separate AI edited it independently.

Put the status region in the page before the job starts

Add an empty paragraph with role="status" near the conversion controls. Keep it mounted and visible, and update its text when your existing job reports an outcome. The role implies aria-live="polite" and aria-atomic="true", so assistive technology can present the whole message at a suitable pause. Leave keyboard focus where the user put it and keep the paragraph out of the tab order. MDN’s status role reference

<p id="processing-status" role="status"></p>

<script>
  const statusNode = document.getElementById('processing-status');

  function showStatus(node, message) {
    node.textContent = message;
  }

  function onProcessingFinished(result) {
    showStatus(
      statusNode,
      `Image conversion finished. ${result.completed} converted, ${result.failed} failed.`
    );
  }
</script>
Enter fullscreen mode Exit fullscreen mode

Wire onProcessingFinished to the completion path that has the final counts. If three files convert and one fails, the numbers should come from those four recorded outcomes. If the job stops early and the counts are unknown, use showStatus with a message such as “Image conversion stopped before a result was available.” Name the operation that actually ran so the result makes sense to someone working elsewhere on the page.

Check the announcement while focus is elsewhere

Before shipping, start a job, tab away from its controls, and listen for the result with the browser and assistive technology combinations you support. Check an all-success run, a run with failed files, and a job that stops before producing counts. Check that focus stays on the control you moved to.

Save this region for meaningful outcomes. A message for every file can bury the final count among progress updates. Try two jobs with the same counts, too. Writing identical text twice may leave the second result unannounced. If the results need to be distinguishable, include a batch name or another detail the user can recognize, then check how each result is announced.

Top comments (0)