Skip to content

Conversation

@codebytere
Copy link
Member

@codebytere codebytere commented Aug 11, 2025

Description of Change

It's been possible to enable accessibility settings on a more granular level for some months now - after #46118 our existing a11y support methods also became more confusing as it's no longer really correct or useful to only see whether accessibility support is enabled as it could be enabled partially and the user has no insight into which parts. This adds two new methods, app.getAccessibilitySupportFeatures() and app.setAccessibilitySupportFeatures(features) allowing the user to access more granular a11y feature management.

Checklist

Release Notes

Notes: Added methods to enable more granular accessibility support management.

@codebytere codebytere requested a review from a team August 11, 2025 13:44
@codebytere codebytere added semver/minor backwards-compatible functionality target/37-x-y PR should also be added to the "37-x-y" branch. target/38-x-y PR should also be added to the "38-x-y" branch. labels Aug 11, 2025
@codebytere codebytere force-pushed the ax-mode-refactor branch 2 times, most recently from 2cabba1 to b413846 Compare August 12, 2025 09:04
Comment on lines 1402 to 1420
### `app.getAccessibilitySupportFeatures()` _macOS_ _Windows_

Returns `string[]` - Array of strings naming currently enabled accessibility support components.Possible values:

* `nativeAPIs` - Native OS accessibility APIs integration enabled.
* `webContents` - Web contents accessibility tree exposure enabled.
* `inlineTextBoxes` - Inline text boxes (character bounding boxes) enabled.
* `extendedProperties` - Extended accessibility properties enabled.
* `screenReader` - Screen reader specific mode enabled.
* `html` - HTML accessibility tree construction enabled.
* `labelImages` - Accessibility support for automatic image annotations.
* `pdfPrinting` - Accessibility support for PDF printing enabled.

Notes:

* The array may be empty if no accessibility modes are active.
* Use `app.isAccessibilitySupportEnabled()` for the legacy boolean check;
prefer this method for granular diagnostics or telemetry.
Copy link
Member

Choose a reason for hiding this comment

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

@codebytere is there a default set of accessibility modes enabled?

Copy link
Member Author

@codebytere codebytere Aug 14, 2025

Choose a reason for hiding this comment

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

@jkleinsc yes, more or less - the way we configured it after the recent refactor was that app.setAccessibilitySupportEnabled() uses ui::kAXModeComplete, which encompasses:

AXMode::kNativeAPIs |
AXMode::kWebContents |
AXMode::kInlineTextBoxes |
AXMode::kExtendedProperties

I wasn't sure whether or how to include that in the new APIs - open to any thoughts!

Copy link
Member

Choose a reason for hiding this comment

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

@codebytere we should just document the above in the docs

Copy link
Member Author

Choose a reason for hiding this comment

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

@jkleinsc done in ba95cb2!

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened recently label Aug 18, 2025
@codebytere codebytere requested a review from jkleinsc August 19, 2025 10:15
@codebytere codebytere force-pushed the ax-mode-refactor branch 2 times, most recently from 49deabe to 3000f89 Compare August 25, 2025 12:57
Copy link
Member

@jkleinsc jkleinsc left a comment

Choose a reason for hiding this comment

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

API LGTM


> [!NOTE]
> Rendering accessibility tree can significantly affect the performance of your app. It should not be enabled by default.
> Rendering accessibility tree can significantly affect the performance of your app. It should not be enabled by default. Calling this method will enable the following accessibility support features: `nativeAPIs`, `webContents`, `inlineTextBoxes`, and `extendedProperties`.
Copy link
Member

Choose a reason for hiding this comment

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

question: would it be more intuitive if we made setAccessibilitySupportEnabled enable all available properties?

Copy link
Member Author

Choose a reason for hiding this comment

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

@erickzhao i'd say no as that'd be a breaking change - this also matches upstream.

### `app.getAccessibilitySupportFeatures()` _macOS_ _Windows_

Returns `string[]` - Array of strings naming currently enabled accessibility support components. Possible values:
Copy link
Member

Choose a reason for hiding this comment

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

I think our docs parser has the ability to generate unions of string literals, though I don't know what the exact syntax is needed to achieve that. @erickzhao pointed me to app.getPath as an API that utilizes this.

It seems like it could be useful to have a more explicit TypeScript type, so that people could get TypeScript warnings for non-exhaustive switch statements, or for passing an invalid string to setAccessibilitySupportFeatures

Copy link
Member

Choose a reason for hiding this comment

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

Actually @MarshallOfSound thinks this should be possible to get specific types for. Ref https://github.com/electron/typescript-definitions/blob/ec3384a33fa0d70d98ffc998b03c771535cc1dd9/src/utils.ts#L153-L167

We might just need to tweak/debug the syntax to get the parser to parse it correctly

@github-actions github-actions bot added the target/39-x-y PR should also be added to the "39-x-y" branch. label Sep 3, 2025
codebytere and others added 2 commits October 15, 2025 12:08
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
Copy link
Member

@reitowo reitowo left a comment

Choose a reason for hiding this comment

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

API LGTM

Copy link
Member

@erickzhao erickzhao left a comment

Choose a reason for hiding this comment

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

API LGTM

Copy link
Member

@itsananderson itsananderson left a comment

Choose a reason for hiding this comment

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

API LGTM

It'd be great to find a way to document the string literal types, but it sounds like there are limitations in the docs parser that make it infeasible right now.

If we merge this as-is, and follow up later to make getAccessibilitySupportFeatures take string literals instead of just string[], it may cause minor typechecking errors for apps that are storing values as string, but it should be an easy thing for those apps to fix the type errors when upgrading.

@jkleinsc jkleinsc merged commit e766d37 into main Oct 21, 2025
150 of 153 checks passed
@jkleinsc jkleinsc deleted the ax-mode-refactor branch October 21, 2025 14:56
@release-clerk
Copy link

release-clerk bot commented Oct 21, 2025

Release Notes Persisted

Added methods to enable more granular accessibility support management.

@trop
Copy link
Contributor

trop bot commented Oct 21, 2025

I have automatically backported this PR to "39-x-y", please check out #48625

@trop
Copy link
Contributor

trop bot commented Oct 21, 2025

I have automatically backported this PR to "38-x-y", please check out #48626

@trop trop bot removed the target/39-x-y PR should also be added to the "39-x-y" branch. label Oct 21, 2025
@trop
Copy link
Contributor

trop bot commented Oct 21, 2025

I have automatically backported this PR to "37-x-y", please check out #48627

@trop trop bot added in-flight/38-x-y in-flight/37-x-y merged/39-x-y PR was merged to the "39-x-y" branch. merged/38-x-y PR was merged to the "38-x-y" branch. merged/37-x-y PR was merged to the "37-x-y" branch. and removed target/38-x-y PR should also be added to the "38-x-y" branch. target/37-x-y PR should also be added to the "37-x-y" branch. in-flight/39-x-y in-flight/38-x-y in-flight/37-x-y labels Oct 21, 2025
TheCommieAxolotl pushed a commit to TheCommieAxolotl/electron that referenced this pull request Nov 2, 2025
* feat: enable more granular a11y feature management

* Update docs/api/app.md

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>

---------

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
nilayarya pushed a commit to nilayarya/electron that referenced this pull request Nov 21, 2025
* feat: enable more granular a11y feature management

* Update docs/api/app.md

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>

---------

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
nilayarya added a commit to nilayarya/electron that referenced this pull request Nov 21, 2025
* feat: enable more granular a11y feature management

* Update docs/api/app.md

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>

---------

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
nilayarya added a commit to nilayarya/electron that referenced this pull request Nov 21, 2025
* feat: enable more granular a11y feature management

* Update docs/api/app.md

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>

---------

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-review/approved ✅ merged/37-x-y PR was merged to the "37-x-y" branch. merged/38-x-y PR was merged to the "38-x-y" branch. merged/39-x-y PR was merged to the "39-x-y" branch. semver/minor backwards-compatible functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants