skip to content

In a music-streaming web app's search box, recent searches and library matches paint instantly but remote suggestions land later; how do you merge them without reshuffling under the arrow key, and what should a screen reader hear?

level: seniorimportance: should knowfreq 40%

answer

  1. placement fixed by product, not arrival
  2. local above remote, reserved space below
  3. dedupe by catalogue id
  4. nothing moves at or above active
  5. one polite count when it settles

basics

~20 s

Fix the layout: local sections on top, remote groups below in reserved space, duplicates removed by catalogue id. Network arrival never moves rows at or above the active one. A polite status region announces one short count when the list settles.

solid answer

~50 s

I fix placement by product rule, not arrival order: up to three matching recent searches and library items on top, then remote groups such as top result, artists, songs and podcasts in a set order, rendering into reserved space so nothing above them moves. Duplicates are merged by catalogue id, keeping the local row. The active option is tracked by id, and a network arrival may never insert, remove or reorder rows at or above it; if the remote ranking would change something above, that waits for the next keystroke. Screen-reader users hear the active option through `aria-activedescendant` as they arrow, and a separate `role="status"` region, which is polite and atomic, says something short like '9 suggestions, 2 from your library' once per query when the list settles, and only when the text changes. 'No suggestions' waits for the remote answer, and nothing is assertive.

go deeper

for a junior

Remember that suggestions arriving late must not move rows the user is about to pick, and that screen readers get one short count, not the whole list.

for a middle

Describe the fixed section order, the reserved space for remote rows and dedupe by id, and the two channels: the active option and a polite status count.

for a senior

Defend the no-reshuffle rule with its cost, show how the settle timer keeps announcements to one per query, and say what happens when remote fails or is empty.

for a principal

Own the trade between ranking quality and stability as a product rule: which teams may claim slots above the fold of the dropdown, and how changes are tested with keyboard and screen-reader users.

## Two sources, two speeds A **music-streaming web app's** global search box has two kinds of answer: - **Local**: the user's recent searches and their saved library (followed artists, saved albums, their playlists). They are already in the tab and filter faster than any network call. - **Remote**: suggestions from the search API, which take hundreds of milliseconds on a phone. If each source simply re-renders the whole list when it arrives, the list changes under the user. They press Down twice to reach a recent search, the remote half lands, the rows jump, and Enter opens a different artist. On a phone the same jump moves a row under a finger that is about to tap. ## The layout contract Placement is decided by the product, **not by which answer arrives first**. | Section | Source | Cap | Appears | |---|---|---|---| | Recent searches that match | local | up to 3 | at once | | In your library | local | up to 3 | at once | | Top result | remote | 1 | when the remote answer lands | | Artists, songs, albums, playlists, podcasts | remote | a few each | when the remote answer lands | Local sections sit **above** remote ones, so the rows a user reaches first are the rows that never wait. Remote sections render into **reserved space**, placeholder rows of fixed height, so their arrival does not push or resize anything above them. ## Dedupe by identity Merge by **catalogue id**, never by title: two artists can share a name. When an item in the library also comes back remotely, keep the local row, which the user may already be on, drop the remote copy, and optionally mark the row "In your library". ## The no-reshuffle rule 1. **Track the active option by catalogue id**, never by row index. 2. **A network arrival never inserts, removes or reorders rows at or above the active row.** 3. While an option is active, remote rows **fill in below** it. If the remote ranking would change something above, that change is **held until the next keystroke**. 4. **A keystroke resets the list:** new text, new list, no active option. 5. The same holds for the **pointer**: no row moves under a hovering pointer or a finger about to tap. Late answers for older text never reach this step; the latest-wins check drops them first. ## What a screen-reader user hears Two channels carry information, and they must not compete. - **The active option.** As the user arrows, `aria-activedescendant` on the input makes the screen reader announce the option. Because ids are stable and nothing above moves, the announced item is the one Enter opens. - **The result count.** A separate status region, `role="status"`, which is implicitly `aria-live="polite"` and `aria-atomic="true"`, so it is read whole when the user is idle. The policy: - update it **once per query, when the list settles**: the remote answer landed, failed, or a short timeout passed; - say a **short summary**, such as "9 suggestions, 2 from your library", never the rows themselves; - change it **only when the text changes**; repeating the same sentence is noise; - say **"No suggestions" only after** the remote answer is empty; - **never assertive**, never move focus, and never make the listbox itself a live region, which would read rows on every render. A fast typist hears one count after they pause, not one per letter, because every keystroke restarts the settle timer. Input-method users hear nothing until their composition ends, because no query is running before then. ## The cost of stability Freezing the rows above the active one means that, for a moment, the best remote match may sit below a weaker local row. The design trades ranking for **predictability**: the user's next keystroke restores the ranking, while a list that moves under the arrow key sends them to the wrong artist. Some products also show the remote "Top result" first; that works only if its slot is reserved from the start, so it fills in place rather than pushing the local rows down. ## Summary Fix placement by rule, reserve the space remote rows will fill, merge duplicates by id, and never move what is at or above the active option. Let the active option speak through `aria-activedescendant`, and give the count one short polite sentence per settled query.

  • The product wants the remote top result above the local sections. Can the list still avoid jumps?
    Yes, if its slot is reserved from the first paint: a fixed-height placeholder row at the top that the top result fills in place. Local rows then start below it and never move. The cost is an empty-looking first row for a few hundred milliseconds on slow links, so the placeholder should look intentional, and it should collapse only on the next keystroke if no top result came back.
  • Why announce the count through a separate status region rather than making the listbox live?
    A live listbox announces its changed content, so every render would read rows aloud while the user is typing or arrowing. A small status region carries one atomic sentence, read when the user is idle, and leaves the options to aria-activedescendant. The two channels then never talk over each other.

  • Render each source as it arrives and re-sort the whole list by score.
  • Track the highlighted suggestion by its row index.
  • Deduplicate local and remote suggestions by matching their titles.
  • Make the suggestion listbox itself aria-live so every change is read.
  • Announce the result count on every keystroke so it always matches the input.
  • Use an assertive region so result counts interrupt and are never missed.