Skip to content

[feat] Add optional alt accessible name to pdf_viewer - #33

Merged
sfc-gh-mbarnes merged 5 commits into
streamlit:mainfrom
mayagbarnes:feat/pdf-viewer-alt
Sep 26, 2026
Merged

sfc-gh-mbarnes merged 5 commits into
streamlit:mainfrom
mayagbarnes:feat/pdf-viewer-alt

Conversation

@mayagbarnes

@mayagbarnes mayagbarnes commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add keyword-only alt: str | None = None to pdf_viewer; include it in the CCv2 data payload only when non-blank
  • Wire ViewerData.alt through to PdfViewer and set aria-label on pdf-container, with role="region" only when alt is present (so unlabeled viewers stay unchanged)
  • Add unit tests for accessible name present / absent / blank

This unblocks Streamlit st.pdf(..., alt=...) (spec phase 4 / pr10-pdf). Streamlit should bump to a published minor (e.g. 2.1.0) after this lands and is released — do not forward alt= against 2.0.1.

Test plan

  • npm test in streamlit_pdf/frontend (36 passed)
  • npm run typecheck

mayagbarnes and others added 2 commits September 24, 2026 11:04
Expose keyword-only alt on the CCv2 data payload and set aria-label
(with role=region) on the viewer root so Streamlit can forward st.pdf alt.

Co-authored-by: Cursor <cursoragent@cursor.com>
Assert unlabeled viewers stay unnamed and that alt sets a computed
accessible name (with role=region) on pdf-container through CCv2.

Co-authored-by: Cursor <cursoragent@cursor.com>
@streamlit streamlit deleted a comment from mayagbarnes Sep 24, 2026
mayagbarnes and others added 2 commits September 24, 2026 11:23
Fix unlabeled alt assertion (Playwright requires a value for
not_to_have_attribute), drop stale BaseWeb select selectors, and remove
an unused height-slider markdown lookup that hit strict mode.

Co-authored-by: Cursor <cursoragent@cursor.com>
Current Streamlit sliders no longer expose a stable role=slider thumb
for bounding_box; hover the stSlider and click like Streamlit own e2e.

Co-authored-by: Cursor <cursoragent@cursor.com>
Pass alt.strip() into CCv2 data and use trimmed string for aria-label so
direct pdf_viewer callers get a clean name; assert blank FE has no name.

Co-authored-by: Cursor <cursoragent@cursor.com>
@sfc-gh-mbarnes
sfc-gh-mbarnes merged commit 271ef3f into streamlit:main Sep 26, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants