-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set rounded rectangle mask on TouchableNativeFeedback's ripples #25342
Conversation
@@ -154,16 +165,18 @@ public void setPointerEvents(ReactViewGroup view, @Nullable String pointerEvents | |||
|
|||
@ReactProp(name = "nativeBackgroundAndroid") | |||
public void setNativeBackground(ReactViewGroup view, @Nullable ReadableMap bg) { | |||
mBg = bg; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a better way to track the current background style object passed into the React Component? I need to keep track of the last background style to reapply the ripple drawable with new border radius styles.
I wasn't sure if assigning this to a variable was the best approach, but I couldn't find another way to do it.
330431b
to
4a8e41a
Compare
CI Failing with:
Huh. Maybe a fluke, upstreaming to retrigger the build. |
6dfe068
to
644afca
Compare
This commit fixes an issue where ripple touch feedback extends beyond the border radius of a view. It achieves this by adding a mask to the RippleDrawable background, collecting that information from two new methods on ReactViewGroup: 1. getBorderRadiusMask() returns a drawable rounded rectangle matching the view's border radius properties 2. getBorderRadius() produces a float[] with the border radius information required to build a RoundedRectShape in getBorderRadiusMask() Additionally, this commit updates setBorderRadius in ReactViewManager to re-apply the background whenever it is set, which is necessary to update the mask on the RippleDrawable background image as the border radius changes. Related issues: facebook#6480
644afca
to
0cc259a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@makovkastar has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Thanks a lot for working on it, looks good! I've made a few changes to add the RTL support for the Regarding storing the background and foreground ReadableMaps in class member variables, I don't know another way to do it, so let's keep it. |
Totally forgot about these. Great! |
This pull request was successfully merged by @nhunzaker in 14b455f. When will my fix make it into a release? | Upcoming Releases |
Heads up: This PR introduced regression: #26544. We are reverting it. Does the regression look anything similar that could be caused by the changes in this commit? |
Aside from the background/elevation regressions this would be a really nice improvement. Not sure if this helps but I found the following in my testing: With With
For For a Plus if the view or any (later?) sibling views have elevation, then the elevation shadow is rendered in front of rather than behind those elevated views when using |
This is definitely a much needed fix. But the background related regression is much worse. So it's not possible to keep this commit right now. A new PR based on this which addresses the regression is very welcome. |
Summary
This commit fixes an issue where ripple touch feedback extends beyond the border radius of a view.
Before
After
The fix
It achieves this by adding a mask to the RippleDrawable background, collecting that information from two new methods on ReactViewGroup:
Additionally, this commit updates setBorderRadius in ReactViewManager to re-apply the background whenever it is set, which is necessary to update the mask on the RippleDrawable background image as the border radius changes.
Related issues:
#6480
Changelog
[Android][fixed] - Adding border radius styles to TouchableNative react-native run-android --port correctly connects to dev server and related error messages display the correct port
Test Plan
Link this branch to a new React native project with the following App.js class:
It's important to ensure that updates to border radius are accounted for. I did this by enabling hot module reloading and updating the border radius styles to verify that the ripple remains correct.