返回提示词目录第 1419 页

无限滚动信息流无障碍改造

检查信息流加载与焦点障碍,提供兼顾键盘和读屏操作的代码改动及测试。

完整提示词

<context>
Pure infinite scroll makes the footer unreachable: every time a keyboard or switch user tabs near the end, more items load and push the footer away, and links to contact, terms or accessibility statements become impossible to reach. Screen-reader users get no signal that more content arrived, and virtualised lists unmount items as they scroll, so focus vanishes and "item 4 of 10" is wrong when the real total is 1,000. The most robust fix is a "Load more" button (focus stays on it or moves to the first new item, and a count is announced); automatic loading can stay for pointer users if the keyboard path does not trigger it, or with a "skip to footer" link and a pause. When a list is virtualised, items need `aria-setsize` and `aria-posinset` (or the total stated in the heading), and the focused item must not be unmounted. The ARIA `feed` role exists for article streams, with `aria-busy` while loading and Page Down and Page Up to move between articles, but its support varies, so a well-structured list with headings plus a load button is often the safer choice. Returning from a detail page should restore the scroll position and the loaded items.
</context>

<task>
Make this {{framework}} feed accessible.

<feed>
{{feed}}
</feed>

1. Read the loading code and list the barriers for keyboard, screen-reader, switch and screen-magnifier users; mark inferences.
2. Recommend a loading pattern for this feed (load-more button, automatic loading with an escape route, or ARIA feed) and justify it in a few sentences.
3. Implement it with the smallest change: a real button for loading more; after loading, either keep focus on the button or move it to the first new item with `tabindex="-1"` (say which and why), and announce "20 more items loaded, 60 of 240" politely. Mark the list `aria-busy` while loading if it is a feed.
4. Keep the footer reachable: no automatic loading triggered by keyboard focus, or a visible skip link to the footer before the feed.
5. For virtualised lists: keep the focused item mounted, expose position and total with `aria-setsize` and `aria-posinset` or a heading with the count, and keep DOM order equal to visual order.
6. Preserve position: restore scroll and loaded pages when the user comes back from a detail view.
7. Write tests for loading with the keyboard, focus after loading and the announcement text; run them. Give a short manual check with a screen reader and with the keyboard only.
</task>

<constraints>
- Do not remove automatic loading for pointer users unless product agrees; offer the escape route first.
- Do not announce every single new item.
- Do not change the API or pagination backend; work with what it returns.
{{> guardrails/scope-discipline}}
{{> guardrails/verify-before-done}}
</constraints>

<output_format>
## Problems found
Numbered, with who is blocked.

## Recommended loading pattern
Short paragraph.

## Changes
Diffs with file paths.

## Tests and manual check
Test code, command result, manual steps.
</output_format>

可替换内容

  • {{framework}}
  • {{feed}}
  • {{> guardrails/scope-discipline}}
  • {{> guardrails/verify-before-done}}

分类与标签

编程开发、无障碍开发、无限滚动、焦点管理、读屏测试

前往 AI 图片创作