Skip to content

Support AccessibilityInfo.isBoldTextEnabled and boldTextChanged on Android - #59176

Open
camilopires wants to merge 1 commit into
react:mainfrom
camilopires:a11y/android-bold-text
Open

camilopires wants to merge 1 commit into
react:mainfrom
camilopires:a11y/android-bold-text

Conversation

@camilopires

Copy link
Copy Markdown

Summary:

On Android, AccessibilityInfo.isBoldTextEnabled() always resolves to false, and boldTextChanged never fires. Android 12 (API 31) added a Bold Text setting, exposed as Configuration.fontWeightAdjustment. Apps currently can't detect it, even though it changes text layout (for example #54931).

This reads fontWeightAdjustment on Android 12 and later and treats a positive adjustment as Bold Text. A negative value means lighter text, and FONT_WEIGHT_ADJUSTMENT_UNDEFINED means the value isn't known; neither counts. The module listens for configuration changes while the app is resumed, reads the value again on resume, and emits boldTextChanged. On Android versions before 12, the method still resolves to false. If the native module predates this change, isBoldTextEnabled still resolves to false rather than rejecting.

RNTester now shows the Bold Text examples on Android.

Discussion: react-native-community/discussions-and-proposals#477

Changelog:

[ANDROID] [ADDED] - AccessibilityInfo.isBoldTextEnabled() and boldTextChanged now work on Android 12 and later

Test Plan:

  • yarn jest packages/react-native/Libraries/Components/AccessibilityInfo: all tests pass
  • yarn flow-check: 0 errors
  • yarn lint: passes
  • yarn build-types --validate: API snapshot up to date
  • yarn test-generated-typescript and yarn test-typescript-legacy: pass
  • yarn format-check-kotlin: passes
  • ./gradlew :packages:react-native:ReactAndroid:testDebugUnitTest --tests "com.facebook.react.modules.accessibilityinfo.*": 4 new tests pass, covering adjustments of 300, 0, -100 and undefined

RNTester on an Android 16 (API 36) emulator, Accessibility → "Check if the display options are enabled":

  • adb shell settings put secure font_weight_adjustment 300 → "Bold Text is enabled."
  • … 0 → "Bold Text is disabled."
  • … -100 (lighter text) → "Bold Text is disabled."
  • Live event without activity recreation. I temporarily added fontWeightAdjustment to RNTester's configChanges, locally and not in this PR, so the activity isn't recreated. Switching 0 → 300 → 0 updated the row in place in the same process.
  • Changed while in the background: set 300, then brought the app back. The row showed "enabled" in the same process.

RNTester on an Android 10 (API 29) emulator: the row shows "Bold Text is disabled." even with the setting at 300, and there were no crashes across launch and resume.

Not run: Android 12–13 (API 31–33) devices. The SDK_INT guard covers them.

…droid

Android 12 (API 31) exposes the Bold Text setting as
Configuration.fontWeightAdjustment. Read it, listen for configuration
changes, and emit boldTextChanged. Earlier versions still resolve to false.
If the native module predates this change, isBoldTextEnabled still
resolves to false.

Adds Kotlin unit tests for the adjustment values, Jest tests for the
getter and the event wiring, and shows the Bold Text examples on Android
in RNTester.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@meta-cla

meta-cla Bot commented Oct 18, 2026

Copy link
Copy Markdown

Hi @camilopires!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@github-actions

Copy link
Copy Markdown

Warning

JavaScript API change detected

This PR commits an update to ReactNativeApi.d.ts, indicating a change to React Native's public JavaScript API.

  • Please include a clear changelog message.
  • This change will be subject to additional review.

This change was flagged as: POTENTIALLY_BREAKING

@meta-cla

meta-cla Bot commented Oct 18, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 18, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Oct 18, 2026

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

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant