Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Unable to getByRole figure with accessible name / description in figcaption

オープン
#1,417 コメント 4 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
52/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
javascript, react
領域
testing

調査の方向性

まず、accessible name と description のオプションを使って、報告された figure マークアップを screen.getByRole で再現します。次に、getByRole における figure と figcaption のセマンティクスの処理を追跡し、その後、クエリが期待される accessible name または description を持つ figure を見つけることを確認します。

索引モデルが issue の本文から書いたものです。

説明

  • @testing-library/react version: 16.3.0
  • Testing Framework and version: jest 30.0.5
  • DOM Environment: jest-environment-jsdom 30.0.5
Relevant code or config:
<figure>
  <figcaption>Foo</figcaption>
  <ul>
    <li>Bar</li>
  </ul>
</figure>
What you did:

What trying to get hold of the figure element using:
const figure = screen.getByRole("figure", { name: "Foo" });
or
const figure = screen.getByRole("figure", { description: "Foo" });
or
const figure = screen.getByRole("figure", { name: /Foo/ });
or
const figure = screen.getByRole("figure", { description: /Foo/ });

What happened:

ShadowDOMTestingLibraryElementError: Unable to find an element with the role of: figure

Reproduction:
Problem description:

Unable to get figure using accessible name / description in figcaption

As per:
https://www.w3.org/WAI/ARIA/apg/practices/names-and-descriptions/

Like with table elements, if a figure is not named using aria-label or aria-labelledby, the content of the figcaption element will be used as the accessible name. However unlike table elements, if the figcaption element is not used for the name, it does not become an accessible description unless it is referenced by aria-describedby. Nevertheless, assistive technologies will render the content of a figcaption regardless of whether it is used as a name, description, or neither.

主要言語
JavaScript
スター
19.7k
フォーク
1.2k
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

testing-library/react-testing-library のほかの issue

testing-library/react-testing-library の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。