Repository navigation
Treat NaN border widths as unset - #57789
RealBhupesh wants to merge 1 commit into
Conversation
|
Hi @RealBhupesh! Thank you for your pull request and welcome to our community. Action RequiredIn 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. ProcessIn 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 If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
@fabriziocucci has imported this pull request. If you are a Meta employee, you can view this in D114520650. |
|
@fabriziocucci merged this pull request in 146aaac. |
Summary:
Resetting a `borderWidth` on Android could clip or hide children in a rounded overflow-hidden view. The root cause is how a reset width is represented.
The border-width prop group is registered with `defaultFloat = Float.NaN` (ReactViewManager.kt), so removing `borderWidth` in JS calls the native setter with `Float.NaN`, not null. `BackgroundStyleApplicator.setBorderWidth` fans that value out to two consumers:
- the border drawable (via `width?.dpToPx() ?: Float.NaN`), which already treats `NaN` as unset.
- `BorderInsets`, which did not.
`BorderInsets.resolve()` falls back with the Elvis operator (`edgeInsets[...] ?: ... ?: 0f`), and `?:` only triggers on null. A non-null `NaN` edge is returned verbatim into the inset `RectF`, which produces a `NaN` content box and inner rounded clip, so children get clipped in overflow-hidden rounded views.
Fix: normalize `NaN` to unset in `BorderInsets.setBorderWidth` (`width?.takeUnless { it.isNaN() }`) so it falls back to the applicable all-edge width, matching what the drawable already does. `setBorderWidth` is the only mutator of the private `edgeInsets` array. `NaN` is never a meaningful width, so nothing legitimate is affected.
- Add a regression test confirming NaN edges fall back to the applicable all-edge width.
## Changelog:
[ANDROID] [FIXED] - Resetting border widths no longer clips children in rounded overflow-hidden views.
Fixes react#57780
Pull Request resolved: react#57789
Test Plan:
- Added `BorderInsetsTest.nanBorderWidthsAreTreatedAsUnset`.
- Android unit tests could not run locally because this environment has no configured Android SDK (`ANDROID_HOME`/`ANDROID_SDK_ROOT`).
Reviewed By: javache
Differential Revision: D114520650
Pulled By: fabriziocucci
fbshipit-source-id: 01afb38c8c5c0811e928e806d6912da5c3071804
* fix(app): show the Android ripple on sidebar row presses PressHighlight owns pressed feedback. Callers pass the pressed fill as highlightStyle and stop painting it themselves. iOS and web paint the fill; Android draws the platform ripple, clipped to the row's corners, after Android's 100 ms tap timeout. Rows that knock content out of the surface follow the fill through onHighlightChange instead of tracking press state themselves. Defaults borderWidth to 0 under clipped ripples: React Native 0.86 sends NaN when a style drops borderWidth, and an overflow-hidden view then stops painting (fixed upstream in react/react-native#57789). * fix(app): let PressHighlight own file header press feedback Changes-tree rows on Android painted their old flat pressed fill under the new ripple. Lock the Android row's caller border and press handlers in a test. * fix(app): skip the sidebar row press fill while renaming On web the row's pressable stays the responder for clicks inside the inline rename field, so it painted the pressed fill while the title was being edited. Drop highlightStyle while editing, as the press handlers already are. * fix(app): keep a press's fill and its report on the same edges usePressFill painted from the live pressed state but reported only at press-in and press-out, so the row fill and the badge ring could disagree when highlightStyle appeared or went away mid-press. A press now keeps the fill it started with; the paint and the report both come from that one state.
…ndroid (#557) ## Problem On Android in dark mode, every screen opened from the drawer turns black: Manage models, Settings, and the chat after you go back. The views are mounted and sit at the right frames (the accessibility tree lists them), but nothing is drawn except the scene's background. The bug comes from #553 and reproduces every time on the Galaxy S25 with both the release and the debug build. ## Cause While the drawer is open, `getRaisedScreenEdge` adds `borderWidth: 0.5` to the scene in dark mode. When the drawer closes the prop is removed, and React Native 0.86 then sends `Float.NaN` to `BackgroundStyleApplicator.setBorderWidth` instead of null. `BorderInsets` stores that value and `resolve()` returns NaN instead of 0, so `ReactViewGroup.dispatchDraw` → `clipToPaddingBox` clips the scene, which has `overflow: 'hidden'`, to an empty rect. Upstream fixed this in react/react-native#57789, which first shipped in 0.88.0. We are on 0.86.3. ## Fix Set `borderWidth: 0` in the base `sceneStyle`, so the prop is never removed. When the drawer is open, `getRaisedScreenEdge` still overrides it with 0.5, so the edge from #553 stays as it is. This line can be removed once we are on RN ≥ 0.88. ## How I checked Debug build on the S25, dark mode, drawer → Manage models: | `sceneStyle` variant | Result | |---|---| | main (#553) | black screen | | conditional `borderWidth` only | black screen | | conditional semi-transparent background only (as in light mode) | renders correctly | | main with `overflow: 'visible'` | renders correctly (the clipping is the cause) | | **main + `borderWidth: 0`** | **renders correctly** | With the fix, Manage models, Settings and going back to the chat all render correctly, and the hairline edge is still visible while the drawer is open. Not affected: iOS (Android-only code), light mode (its raised edge has no border), and the 1.4.0 store build (`release/1.4.0` does not include #553).
Summary
Float.NaNborder widths to unset values in the shared logical border-inset resolver.Changelog:
[ANDROID] [FIXED] - Resetting border widths no longer clips children in rounded overflow-hidden views.
Fixes #57780
Test plan
BorderInsetsTest.nanBorderWidthsAreTreatedAsUnset.ANDROID_HOME/ANDROID_SDK_ROOT).