Skip to content

Keep poll labels readable over their bars on Android - #184

Merged
simonhamp merged 1 commit into
NativePHP:mainfrom
shanesmithdev:fix-android-poll-bars
Nov 20, 2026
Merged

simonhamp merged 1 commit into
NativePHP:mainfrom
shanesmithdev:fix-android-poll-bars

Conversation

@shanesmithdev

@shanesmithdev shanesmithdev commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Status: Ready for review. Not blocked.

Fixes #174.

On Android, a poll's results hid each option's label behind its share bar: "Help and advice" read as "and advice", and an option with a big share showed no label at all. iOS was fine.

Each option is a box with the bar as an absolute layer, written before the label so it sits behind it. iOS draws layers in the order they're written. Android doesn't: NativePHP's FlexContainer (ComposeFlexLayout.kt) composes every flow child first and then every absolute child over them, whatever the order. So on Android the bar always covered the label.

I have also reported this upstream as NativePHP/mobile-air#712. EDGE has no z-* to override it, and 4.8.0 and main behave the same.

What changed

  • An option's label row is now its own partial, poll-option-label, drawn twice:
    • an invisible copy (opacity-0) in the flow, which gives the option its height, as the label always did
    • the visible copy as an absolute layer after the bar, so it's on top on both platforms
  • The option's a11y-label already stands in for everything inside it (accessibilityElement(children: .ignore) on iOS, clearAndSetSemantics on Android), so VoiceOver and TalkBack still read each option once.
  • The bar, the copy and the label have refs (poll-bar-*, poll-sizer-*, poll-label-*), and the existing poll tests use poll-bar-* instead of children[0].
  • A test checks the layers' order and that the invisible copy draws exactly what the label does (type, props, style and layout), so the two can't drift apart and leave the label clipped or off-centre.

Each result option has a row, two texts, a spacer and, for your vote, an icon more than before. A poll has at most four options, so it's a few views per poll. Once mobile-air#712 is fixed, this can go back to a single label row.

Screenshots

iOS light iOS dark Android light Android dark
Before
After

Android was taken on a phone (a Samsung, since the Android emulator can't run the app on an Apple M4 Mac) and iOS on an iPhone 17 Pro simulator. Android shows the fix. iOS looks the same before and after, as it should.

Testing

  • php artisan test --compact for CommitCardTest, PollVoteTest, ComposerPollTest, ComposerPreviewTest and ScheduleCommitTest: 46 passed.
  • The new test fails before the change. Its check that the copies match was mutation-tested: giving only the visible copy a different font, or taking flex-shrink off only its label, makes it fail.
  • Checked on the phone and the simulator, light and dark, on two closed polls (8e785a0's related commits) with shares from 0% to 84%.

On Android a poll's results hid each option's label behind its share
bar, so "Help and advice" read as "and advice" and an option with a big
share showed no label at all. iOS was fine.

The bar is an absolute layer written before the label so it sits
behind it. iOS draws layers in the order they're written, but
NativePHP's Android FlexContainer draws every absolute child after the
flow ones, whatever the order (NativePHP/mobile-air#712).

The label row is now a partial drawn twice: an invisible copy in the
flow that gives the option its height, and the copy you see as an
absolute layer after the bar, so it's on top on both platforms. The
option's a11y-label still stands in for everything inside it, so
screen readers read each option once. A test checks the order and that
the two copies draw the same thing, so they can't drift apart.

Fixes NativePHP#174.
@shanesmithdev

Copy link
Copy Markdown
Contributor Author

FYI @simonhamp

@simonhamp
simonhamp merged commit 38d9626 into NativePHP:main Nov 20, 2026
4 checks passed
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.

Poll progress bars make the text unreadable

2 participants