Skip to content

Fix per-side border colors drawing outside the view on Android - #59787

Merged
javache merged 3 commits into
react:mainfrom
shubh73:fix/android-border-quadrilateral-style
Nov 18, 2026
Merged

javache merged 3 commits into
react:mainfrom
shubh73:fix/android-border-quadrilateral-style

Conversation

@shubh73

@shubh73 shubh73 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

On Android, a border without a radius that changes from one color to per-side colors is drawn wrong: each side spills outside the view.

With per-side colors, BorderDrawable.drawRectangularBorders draws each side as a filled quadrilateral, but never sets the paint's style. Drawing the border with one color leaves the paint on STROKE with the border width, so after the change each quadrilateral is stroked instead of filled. drawRoundedBorders already sets FILL for per-side colors; this does the same here. It's the same kind of leftover paint state as #59607.

Changelog:

[ANDROID] [FIXED] - Fix per-side border colors drawing outside the view after the border had a single color

Test Plan:

Added unevenBorderColorsAreFilledAfterAUniformBorderColorWasDrawn to BorderDrawableTest. It fails on main (STROKE instead of FILL) and passes with this change.

./gradlew :packages:react-native:ReactAndroid:testDebugUnitTest --tests "com.facebook.react.uimanager.drawable.BorderDrawableTest"

Added a Changing to per-side colors example to RNTester's Border examples, and a step to the Border visual test that taps it and captures border/color-change/per-side-colors, so a regression shows up as a visual diff. Ran the Border flow with Maestro 2.6.1 on an OPPO K12x 5G (CPH2667, Android 16) against RNTester Release built with and without the fix:

maestro test -e APP_ID=com.facebook.react.uiapp -e VISUAL_OUTPUT_DIR=/tmp/visual packages/rn-tester/visual-tests/flows/border.yml

Without the fix, the new capture shows each side spilling outside the box; with it, the four sides sit inside the box. Two runs of each build gave byte-identical captures, and the existing corner-radii, child-clipping-radius and equal-width-borders captures are identical with and without the fix.

Also checked in RNTester on an OPPO K12x 5G (CPH2667, Android 16) and a Pixel 9 emulator (API 36) with:

function Example() {
  const [perSide, setPerSide] = useState(false);
  useEffect(() => {
    const timeout = setTimeout(() => setPerSide(true), 300);
    return () => clearTimeout(timeout);
  }, []);
  return (
    <View
      style={[
        {width: 80, height: 50, borderWidth: 10},
        perSide
          ? {
              borderTopColor: 'red',
              borderLeftColor: 'green',
              borderRightColor: 'blue',
              borderBottomColor: 'orange',
            }
          : {borderColor: 'black'},
      ]}
    />
  );
}
Before After
Before After

Other borders and backgrounds on the same screen (solid, dashed and dotted, radii, per-side widths, translucent colors) are pixel-identical before and after.

yarn format-check-kotlin passes.

🤖 Generated with Claude Code

@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 Nov 3, 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 Nov 3, 2026
@javache

javache commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Could you add the example to RNTester that demonstrates the issue so we can prevent regressions?

@shubh73

shubh73 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

done, added a "changing to per-side colors" example to the border examples and a step in the border visual test that captures it after the change.

@meta-codesync

meta-codesync Bot commented Nov 4, 2026

Copy link
Copy Markdown

@javache has imported this pull request. If you are a Meta employee, you can view this in D129590218.

@christophpurrer christophpurrer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review automatically exported from Phabricator review in Meta.

@javache

javache commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Can you rebase this diff? CI seems stuck on some builds.

shubh73 and others added 3 commits November 18, 2026 16:42
When a border without a radius has different colors per side, BorderDrawable
draws each side as a filled quadrilateral, but that branch never set the
paint's style. A drawable first drawn with one border color leaves its paint
on STROKE with the border width, so after a change to per-side colors the
sides were stroked and spilled outside the view. Set the style to FILL there,
as the rounded branch already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…er colors

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@shubh73
shubh73 force-pushed the fix/android-border-quadrilateral-style branch from 445d20a to 78d3e25 Compare November 18, 2026 11:12
@shubh73

shubh73 commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

rebased

@github-actions

Copy link
Copy Markdown

Visual regression

2 visual difference(s) at 78d3e25f4412. Visual differences need maintainer approval. Review the report, then apply visual-change-approved.

android border/color-change/per-side-colors: New

Captured
Captured
captured

ios border/color-change/per-side-colors: New

Captured
Captured
captured

@javache
javache merged commit 13b3b85 into react:main Nov 18, 2026
92 of 95 checks passed
meta-codesync Bot pushed a commit that referenced this pull request Nov 19, 2026
The `Visual regression (android)` and `(ios)` checks fail on any difference, and applying `visual-change-approved` only passes the `Visual regression approval` gate, so an approved PR still shows two red checks - eg #59787, where both platforms only differ by the new test it adds.

This makes the platform checks neutral when there are differences, so the gate is the only visual check that fails, and only until the differences are approved. None of the visual checks are required, and a neutral check doesn't fail a PR's overall status. Removing the label, or a push that changes the differences, fails the gate again as before.

Changelog: [Internal]

Test plan:
New unit test. Also ran the compare step's `report` against #59787's real report with the GitHub API mocked: both platform checks post `neutral`, and the gate posts `failure` without the label and `success` ("approved by @javache") with it.

Differential Revision: D132905555

Pull Request resolved: #60110
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. visual-change-approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants