fix(android): make EditText accessible with display: contents#6
Merged
janicduplessis merged 1 commit intomainfrom Apr 27, 2026
Merged
Conversation
The decorator view uses style={{ display: 'contents' }} so it doesn't
take layout space, but on Android Fabric this caused the inner EditText
to be missing from the accessibility tree. Number-pad/phone-pad inputs
silently rejected all keystrokes (the IME has nothing to commit text
into). Default keyboard inputs happened to work because they go through
a different commit path.
The shadow node already removed the ForceFlattenView trait so a host
view is created, but the child's Yoga-computed metrics weren't being
propagated to the now-non-flat decorator. Override layout() to copy
the child's metrics onto the decorator and zero out the child's origin
(now relative to the decorator). Mirrors react-native-live-markdown's
approach for the same setup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The decorator view uses
style={{ display: 'contents' }}so it doesn't take layout space. On Android Fabric this caused the innerEditTextto be missing from the accessibility tree entirely. The visible symptom:keyboardType=\"number-pad\"and\"phone-pad\"inputs silently rejected every keystroke (the IME has nothing to commit text into). Default keyboard inputs happened to work because they go through a different commit path, which is why this stayed hidden.Reproduced with agent-device on a fresh build of the example app: only the manually-added plain RN
<TextInput>showed up in the AX tree as[text-field]. Every TransformerTextInput-wrapped input was missing theEditTextnode — the entire input slot was empty in the AX tree.Solution
The shadow node already removed the
ForceFlattenViewtrait so RN creates a host view despitedisplay: contents. What was missing was propagating the child's Yoga-computed metrics to the now-non-flat decorator. Overridelayout()in the C++ shadow node to copy the child's metrics onto the decorator and zero out the child's origin (which is now relative to the decorator). Mirrors react-native-live-markdown's approach for the same setup.After the fix, all four
EditTextnodes show up in the AX tree and number-pad/phone-pad typing works.Test plan