skip to content

In a community-board web app's windowed feed, what do screen-reader and keyboard users lose when off-screen posts leave the DOM, and how would you compensate?

level: seniorimportance: should knowfreq 44%

answer

  1. only the window exists
  2. find-in-page, count, position, focus
  3. the feed pattern's articles and set size
  4. never unmount the focused post
  5. Page Down between articles

basics

~20 s

Unrendered posts vanish from find-in-page and from a screen reader's reading, count and position, and an unmounted focused post drops focus. Compensate with the feed pattern's ARIA and keys, pin the focused post, and keep nearby posts rendered.

solid answer

~50 s

Windowing removes off-screen posts from the DOM, so find-in-page cannot match them, a screen reader cannot read them or tell how many there are or where the reader is, and if a focused post's Like button is unmounted, focus falls back to the page. I'd implement the feed pattern: a container with role `feed` and a label, each post an `article` that can take focus, `aria-labelledby` and `aria-describedby` for skim reading, `aria-posinset` with its position in the whole loaded list and `aria-setsize` as the loaded count or -1 when the total is unknown, and `aria-busy` while posts are added. Page Down and Page Up move focus between articles. The list never unmounts the post holding focus, keeps a few posts beyond the viewport rendered, and windows only far pages so the posts near the reader stay findable.

code

html · 12 lines
html
<h2 id="feed-title">Neighbourhood posts</h2>
<div role="feed" aria-labelledby="feed-title" aria-busy="false">
  <article tabindex="-1" aria-posinset="201" aria-setsize="-1"
           aria-labelledby="p8812-author p8812-title"
           aria-describedby="p8812-body">
    <h3 id="p8812-title">Lost cat on Elm Street</h3>
    <p id="p8812-author">Posted by Dana, 2 hours ago</p>
    <p id="p8812-body">Grey tabby, answers to Pepper...</p>
    <button type="button">Like (14)</button>
  </article>
  <!-- more articles; the container's padding holds the height of unrendered posts, since all feed content sits inside articles -->
</div>

go deeper

for a junior

Recall that a windowed list removes off-screen posts from the page, so find-in-page and screen readers only see what is rendered.

for a middle

Explain the feed pattern's roles and attributes, including aria-setsize of -1 for an unknown total and resetting aria-busy after an update.

for a senior

Design the window around assistive technology: pin the focused post, keep a buffer, load before the end, keep positions stable, and plan for find-in-page.

for a principal

Weigh windowing's accessibility cost against its memory saving, and make reading-mode and keyboard testing a release gate for the feed.

## What windowing takes away A **windowed** feed renders only the posts near the viewport. Everything else is a spacer. That saves memory and work, but every tool that reads the DOM now sees only the window: | Reader tool | What it relies on | What windowing breaks | |---|---|---| | Find-in-page | text in the DOM | posts outside the window cannot be found | | Screen reader reading mode | the accessibility tree built from the DOM | posts outside the window cannot be read; the reader hits an artificial end | | Item count and position | the list's structure | "post 4 of 12" describes the window, not the feed | | Keyboard focus | the focused element staying in the DOM | unmounting the focused post drops focus to the page | | Tab order | focusable elements in the DOM | tabbing stops at the window's edge | By contrast, `content-visibility: auto` keeps off-screen content in the DOM and the accessibility tree, so these keep working. That is one reason to window only the far pages of a feed and keep the region around the reader fully rendered. ## The feed pattern The ARIA feed pattern was designed for exactly this: a scrolling list of articles that loads and removes content as the reader moves. It sets up an agreement. The **page** scrolls the article that has DOM focus into view and loads or removes articles based on which article holds focus. **Assistive technology** with a reading mode moves focus to the next and previous articles as the reader goes. - The container has role `feed` and a name: `aria-labelledby` pointing at a visible heading, or `aria-label`. - Each post is an `article` (element or role), focusable with `tabindex="-1"` or `tabindex="0"`. - Each article has `aria-labelledby` pointing at a distinguishing label (author and title) and, strongly recommended, `aria-describedby` pointing at the main content, so readers can skim article by article. - `aria-posinset` gives the article's position **in the whole feed**, not in the current window. - `aria-setsize` gives either the number of articles loaded or the total in the feed, whichever helps more; `-1` when the total is unknown, the usual case for an endless feed. - While posts are added or removed in several DOM operations, the feed has `aria-busy="true"`, and it **must** be set back to `false` afterwards or some readers may not see the change. ## Keyboard keys The feed role has no built-in keyboard convention, so the page provides one. The recommended keys when focus is inside the feed: 1. **Page Down** moves focus to the next article. 2. **Page Up** moves focus to the previous article. 3. **Control + End** moves focus to the first focusable element after the feed. 4. **Control + Home** moves focus to the first focusable element before the feed. Because these are not a desktop convention, the feed should document them where keyboard users will find them, such as a short help note reachable before the feed. ## Rules the window must obey - **Never unmount the focused post.** If the reader focused a post's Like button and then scrolled with the wheel, keep that post rendered, out of view, until focus moves elsewhere. - **Keep a buffer.** Render a few posts beyond each edge of the viewport, so Page Down always has a real next article to move to. - **Load before the end.** The next page should arrive before focus reaches the last loaded article, so reading mode does not hit a false end. - **Do not insert or remove in the middle.** New posts wait behind a banner; deletions near the reader become placeholders of the same height. - **Keep positions stable.** An article's `aria-posinset` should not change while the reader is on it. ## Find-in-page There is no ARIA fix for find-in-page. Options, in order of preference: - Window only far pages, so the posts the reader has recently seen stay findable. - Offer a search box for the feed that queries the server, since the browser's find cannot see what is not rendered. - Accept the gap for very old pages and say so in the design. ## What interviewers listen for - Naming the concrete losses: find-in-page, reading, count and position, focus. - The feed pattern's roles and attributes, with `aria-setsize="-1"` for an unknown total. - The focus-pinning rule and the buffer around the viewport. - A plan to test with a screen reader in reading mode and with keyboard only.

  • Should aria-setsize show the number of posts loaded so far or -1?
    Either is allowed. The loaded count gives the reader a sense of how far they are into what is on hand but changes with every page; -1 says honestly that the total is unknown. For an endless neighbourhood feed, -1 is usually clearer, and the posinset still tells the reader how deep they are.
  • A post contains a photo carousel that uses Page Down internally. What happens to feed navigation?
    When focus is inside a widget that uses the feed keys, the widget handles them, so the reader must move focus out of the carousel to continue through the feed. Avoid giving in-post widgets those keys, or provide another way out, such as Control + End to the next element after the feed.

  • Windowing is invisible to screen readers because they read the whole page anyway.
  • aria-setsize should be the number of posts currently in the window.
  • aria-busy can be set to true while loading and left that way.
  • A feed needs no keys of its own; tabbing through every post is enough.
  • If the focused post scrolls out, unmount it; focus will move on by itself.