Skip to content

Omit redundant role="heading" on native heading elements - #2898

Open
bencripps wants to merge 1 commit into
necolas:masterfrom
bencripps:fix/omit-redundant-heading-role
Open

bencripps wants to merge 1 commit into
necolas:masterfrom
bencripps:fix/omit-redundant-heading-role

Conversation

@bencripps

Copy link
Copy Markdown

Fixes #2780.

Text with accessibilityRole="header" (or role="heading") already renders an h1–h6. createDOMProps was also setting role="heading" on that element. An explicit heading role overrides the tag's implicit level, so axe no longer counts it as a real heading (h1[role="heading"]).

Native headings now keep their implicit role. A non-heading host, such as a div, still receives role="heading".

Test plan

  • propsToAccessibilityComponent still maps a heading role to h1 / hN
  • createDOMProps('h1' | 'h3', …) does not set role
  • createDOMProps('div', { role: 'heading' }) still sets role="heading"
  • createElement renders <h1> and <h2> with no role attribute
  • jest for createDOMProps and createElement (72 tests)

Made with Cursor

An explicit heading role overrides the implicit level of h1–h6, so axe no longer treats them as real headings.
@codesandbox-ci

codesandbox-ci Bot commented Oct 8, 2026

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit e34775f:

Sandbox Source
react-native-web-examples Configuration

This branch has not been deployed

No deployments
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.

A11y Text accessible role "heading" render redundant role

1 participant