Skip to content

fix: hide childless container views from the accessibility tree - #53460

Closed
wittjeff wants to merge 2 commits into
electron:mainfrom
wittjeff:fix/empty-content-view-a11y
Closed

wittjeff wants to merge 2 commits into
electron:mainfrom
wittjeff:fix/empty-content-view-a11y

Conversation

@wittjeff

@wittjeff wittjeff commented Sep 3, 2026 •

Copy link
Copy Markdown

Description of Change

Since #41256, a BrowserWindow's WebContentsView is a sibling of the window's contentView, inserted before it so that contentView children paint on top of the web contents. BaseWindow auto-creates its contentView as a plain views::View covering the whole window, and that container sits above the web contents in the view order.

ViewAXPlatformNodeDelegate::HitTestSync searches children topmost-first and returns the first child whose HitTestPoint() succeeds. With a plain bounds check, the full-window contentView wins every accessibility hit-test over the web contents beneath it, whether or not it has children: with no children it is the final result (the empty pane in #42945, bisected to 30.0.0-beta.8 / #41256), and with children it still wins for every point outside them, e.g. anywhere outside a BrowserView. NVDA's mouse tracking lands on the empty pane and goes silent.

View::HitTestPoint() is GetEffectiveViewTargeter()->DoesIntersectRect(), so a ViewTargeter on contentView governs both mouse targeting and accessibility hit-tests. macOS already installs exactly such a targeter (ContentViewTargeterDelegate, from #50330 and #51617) so mouse events fall through to the WebContentsView. This PR:

  • Moves that delegate into NativeWindow::InstallContentViewTargeter() and calls it from both NativeWindowMac::SetContentView and NativeWindowViews::SetContentView, so on Windows and Linux contentView only intersects a point where one of its visible children does. Accessibility hit-tests and views mouse targeting then fall through to the WebContentsView wherever no child covers the point, regardless of how many children contentView has. macOS behaviour is unchanged.
  • Marks a default-constructed api::View's plain container as ignored while it has no children, so the empty pane also disappears from tree navigation (the extra pane seen in Inspect.exe). As soon as children are added it returns to the tree. Views wrapped by api::View subclasses (WebContentsView, ImageView, etc.) are unaffected.

On Windows and Linux, mouse events over web content are delivered to the RenderWidgetHostViewAura window and never reach the views RootView, so the targeter only changes views targeting where neither web content nor a contentView child is under the point; there the target becomes the main view instead of the empty container, and neither handles mouse events.

Verification

Linux, AT-SPI Component.GetAccessibleAtPoint from the window frame (same HitTestSync path), Xvfb, app.setAccessibilitySupportEnabled(true). Baseline is Electron 44.2.0; "patched" is this branch.

Scenario Point Baseline Patched
empty contentView window centre empty panel (contentView) document web
40x40 child in corner window centre panel (contentView, 1 child) document web
40x40 child in corner inside child panel (child) panel (contentView; childless child is ignored)
40x40 child in corner beside child panel (contentView, 1 child) static "Hello a11y" (web content)
BrowserView 200x150 window centre panel (contentView, 1 child) document web
BrowserView 200x150 inside BrowserView document web (BrowserView) document web (BrowserView)
BrowserView 200x150 beside BrowserView panel (contentView, 1 child) paragraph (web content)

The empty contentView no longer appears under the main view in the tree. Not verified on Windows with NVDA / Inspect.exe; repro steps are in #42945. cc @codebytere

Fixes #42945

Checklist

  • PR description included and stakeholders cc'd
  • npm test passes locally — Linux build verified with the AT-SPI hit-tests above; native accessibility hit-testing is not observable from the JS specs
  • relevant documentation is changed or added — no API change
  • PR release notes describe the change in a way relevant to app developers, and are capitalized, punctuated, and past tense

Release Notes

Notes: Fixed screen readers detecting an empty pane instead of the window's web contents (e.g. broken NVDA mouse tracking) caused by the BrowserWindow's contentView container overlaying the WebContentsView in the accessibility tree.

🤖 Generated with Claude Code

Since the BrowserWindow's WebContentsView became a sibling of the
window's contentView painted beneath it (electron#41256), the empty contentView
container has been exposed to assistive technology as an empty pane
covering the whole window. ViewAXPlatformNodeDelegate::HitTestSync
searches children topmost-first and returns the empty pane, so screen
reader hit-tests (e.g. NVDA mouse tracking) can no longer reach the web
contents beneath it.

Mark a default-constructed api::View's plain container as ignored and
invisible to accessibility while it has no children. Ignored removes
the empty pane from the accessibility tree; invisible makes AX
hit-tests skip it so they fall through to the web contents. The state
is cleared as soon as child views are added, so contentView-based
layouts (e.g. multiple WebContentsViews) are still fully exposed to
assistive technology. This follows the pattern of Chromium's
ash::NonAccessibleView.

Fixes electron#42945

Co-Authored-By: Claude Fable 5 <[email protected]>
@welcome

welcome Bot commented Sep 3, 2026

Copy link
Copy Markdown

💖 Thanks for opening this pull request! 💖

Semantic PR titles

We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix.

Examples of commit messages with semantic prefixes:

  • fix: don't overwrite prevent_default if default wasn't prevented
  • feat: add app.isPackaged() method
  • docs: app.isDefaultProtocolClient is now available on Linux

Commit signing

This repo enforces commit signatures for all incoming PRs.
To sign your commits, see GitHub's documentation on Telling Git about your signing key.

PR tips

Things that will help get your PR across the finish line:

  • Follow the JavaScript, C++, and Python coding style.
  • Run npm run lint locally to catch formatting errors earlier.
  • Document any user-facing changes you've made following the documentation styleguide.
  • Include tests when adding/changing behavior.
  • Include screenshots and animated GIFs whenever possible.

We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.

@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Sep 3, 2026
Comment thread shell/browser/api/electron_api_view.cc Resolved

@MarshallOfSound MarshallOfSound left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repro'd #42945 on Linux by hit testing through AT-SPI, which goes through the same HitTestSync path. This does fix the default case, the centre of the window now resolves to the page instead of an empty panel.

It doesn't cover a contentView that has children though, see inline. That includes every BrowserView, since addBrowserView puts its view in contentView, so I'd like to see that handled before we land this.

Comment thread shell/browser/api/electron_api_view.cc Resolved
…point

Share the ContentViewTargeterDelegate that macOS already installs on
content_view_ with the views platforms so ViewAXPlatformNodeDelegate::HitTestSync
falls through to the sibling WebContentsView wherever no child covers the
point, not just while the container is childless. Keep the childless
container ignored so the empty pane stays out of the accessibility tree.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@rafa11rodrigues

Copy link
Copy Markdown

Hi

Thank you so much for addressing this accessibility bug, it will be a huge improvement in low vision user's experience.

Do you have a timeline to finalize the PR and have a new version available in npm?

Thanks!

@wittjeff

Copy link
Copy Markdown
Author

Thanks @rafa11rodrigues, glad it's useful.

I can't give a date, since merging and releasing are up to the Electron maintainers, but here's where it stands:

  • After @MarshallOfSound's review I reworked the approach (3fca87e) so it also covers a contentView that has children, such as a BrowserView. It's verified on Linux via AT-SPI hit-testing; I still want to confirm it on Windows with NVDA.
  • Recent refactors on main have left the branch conflicting, so the next step is a rebase. After that I'll take it out of draft for re-review.

Once it merges it'll ship in the next nightly/alpha. Whether it gets backported to the current stable releases is up to the maintainers.

@wittjeff

Copy link
Copy Markdown
Author

Change of plans: I won't be able to follow up on this properly for about 2 weeks, sorry.

@avrilmai

avrilmai commented Oct 25, 2026 •

Copy link
Copy Markdown

This PR was left with two open items: a rebase on main (recent refactors in electron_api_view.cc changed the View/Host structure) and the Windows verification with NVDA / Inspect.exe.

I picked both up. The same fix, rebased on current main and with the missing Windows verification measured through the Windows UI Automation and MSAA APIs, is now proposed in #55334.

(An earlier pull request, #55323, carried the same branch; GitHub closed it automatically a few seconds after it was opened, because the description did not yet contain the sections the template check looks for. The description was corrected, but GitHub then refused to reopen that pull request, so the branch is proposed again under #55334.)

Two differences worth noting for review:

  • main already ships electron::ContentViewTargeterDelegate in shell/browser/ui/views/content_view_targeter_delegate.h, used by the macOS paths. The new PR installs that same delegate on Windows and Linux, instead of moving it to native_window.cc as this PR does.
  • The "hide the childless container" part is scoped to the container that BaseWindow creates. A view set by the application through setContentView keeps its accessibility node, which this PR does not guarantee.

@wittjeff feel free to close this one, or to take the fix commits from #55334 if you prefer to continue here.

@wittjeff

wittjeff commented Nov 2, 2026

Copy link
Copy Markdown
Author

Closing in favor of #55334, which continues this work: it rebases the same fix on current main, reuses the ContentViewTargeterDelegate that main already ships for macOS, and adds the Windows/UIA verification this PR was waiting for. Thanks to @avrilmai for picking it up — #42945 should be tracked there. 🙏

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.

[Bug]: NVDA screen reader no longer works since 30.0.0-beta.8

4 participants