-
Notifications
You must be signed in to change notification settings - Fork 3k
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
#3019 move pointerEvents style from Image to View for Avatar #3129
#3019 move pointerEvents style from Image to View for Avatar #3129
Conversation
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.
This looks OK, but would it be easier to just add a View
around the Avatar
component here... ?
@marcaaron You are right. It's definitely easier. I wasn't sure if that would be considered a good practice, to have an extra nested View just for that style, since in some places around the app, If you believe I should create a view with that style inside There is one place where avatars are rendered, but actual Avatar component is not used in So I would need to include |
Good point. It could make things unnecessarily heavy, but I'm not sure if there are any bad effects. If we have mostly cases of Avatars with e.g. <View style={[styles.someStyle]}>
<Avatar />
</View> would be converted to <Avatar containerStyles={[styles.someStyle]} /> |
Ultimately, I think what we want is to not have to remember to put an |
The
This is a very good point. I'll convert the PR to draft and rework it. Thanks. |
I've applied your suggestions. Named the prop |
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.
Nice simplification from the original PR, just one question
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.
LGTM, @marcaaron all yours
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.
Looks good to me just had one minor comment.
src/components/Avatar.js
Outdated
@@ -10,13 +10,17 @@ const propTypes = { | |||
/** Extra styles to pass */ | |||
style: PropTypes.arrayOf(PropTypes.any), | |||
|
|||
/** Extra styles to pass to View wrapper */ | |||
containerStyle: PropTypes.arrayOf(PropTypes.any), |
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.
Can this be containerStyles
since we are accepting an array of style objects?
Also should be PropTypes.arrayOf(PropTypes.object)
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.
Named the prop containerStyle instead of containerStyles to be more in line with similar prop names across the app. Also made sure the new wrapper style is always there no matter what you pass with containerStyle.
There is a guide here on the correct usage -> https://github.com/Expensify/Expensify.cash/blob/main/STYLING.md#complex-component
Probably we need to update some other incorrect usages :)
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.
There are at least ten props in the app that end with style
(not styles
) and most of them accept any
. Do I change all the ones I could find? The way I see it, it's outside the scope of the issue, especially assuming I am expected to test each change.
I'll change the naming and proptype for the new containerStyle
prop and I guess the existing style
prop of Avatar
component too, if that's ok.
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.
No, please only change this specific instance.
If we see a style
prop that means it can accept either an array or object. It's explained here.
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.
Ok, does it mean that proptype should be
/** Additional styles to add after local styles */
style: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.object),
PropTypes.object,
]),
instead of PropTypes.arrayOf(PropTypes.any),
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.
No, because this is not a style
prop for a simple component, but specifically targets the wrapper element so we are looking for:
containerStyles: PropTypes.arrayOf(PropTypes.object)
Let me know if that makes sense or if the readme can be clearer about this somehow.
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.
No, I mean the style
prop, not containerStyles
.
It was style: PropTypes.arrayOf(PropTypes.any),
before I touched it, my question is should it be
style: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.object),
PropTypes.object,
]),
Since it's a simple style prop it should accept both object and array, as per styling guide.
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.
Pushed an update. The way I see it, it's either like this or we rename the style
prop to something like imageStyles
and allow only array of objects there. If I understand the styling guidelines correctly, this how it is meant to be if you pass 2 style props: all of them should be plural, must have names describing the target element and accept only array of objects.
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.
Yes, but we should not have a combination of style
and containerStyles
either we have multiple elements and we are getting specific or a single element and we are being vague.
It's totally fine if you don't want to make the change. We have some clean up to do and are still figuring some things out.
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.
Sorry @dklymenk the pointerEvents
should be on the View
itself like this:
<View pointerEvents="none">
src/styles/styles.js
Outdated
@@ -1030,6 +1028,10 @@ const styles = { | |||
borderColor: themeColors.sidebar, | |||
}, | |||
|
|||
avatarWrapper: { | |||
pointerEvents: 'none', | |||
}, |
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.
I think maybe the initial guidance was wrong because pointerEvents
should be a prop on the View
not a style
@marcaaron |
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.
Awesome thanks for the changes!
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
@marcaaron Please check out the fix for https://github.com/Expensify/Expensify.cash/pull/3092/files#r639059422
Details
Since there is no
pointerEvents
style on react native Image, and we need to apply that style to a View instead, a newavatarWrapper
style was created and all Avatars across the app now have a wrapping View with that style.Fixed Issues
Fixes #3019
Tests
QA Steps
Mobile web Safari iOS:
Bug5076490_Looking_weird.mp4
Other platforms:
Try doing the same for any avatar on the app. All the avatars should be covered by this PR, not just the one mentioned on the original issue #3019
Tested On
Screenshots
Web
Mobile Web
Desktop
iOS
Android