Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

MM-15709 certain aspect ratio of images cause pop on firefox #2826

Merged
merged 2 commits into from
May 22, 2019

Conversation

sudheerDev
Copy link
Contributor

Dimensions here are numbers and need to have px appended so that the styles are applied

https://mattermost.atlassian.net/browse/MM-15709

* Svg's need max dimention styles with px suffix
@sudheerDev sudheerDev added 2: Dev Review Requires review by a core commiter CherryPick/Candidate A candidate for a quality or patch release, but not yet approved labels May 20, 2019
@sudheerDev sudheerDev added this to the v5.12.0 milestone May 20, 2019
@@ -120,7 +120,7 @@ export default class SizeAwareImage extends React.PureComponent {
<svg
xmlns='http://www.w3.org/2000/svg'
viewBox={`0 0 ${dimensions.width} ${dimensions.height}`}
style={{verticalAlign: 'middle', maxHeight: `${dimensions.height}`, maxWidth: `${dimensions.width}`}}
style={{verticalAlign: 'middle', maxHeight: `${dimensions.height}px`, maxWidth: `${dimensions.width}px`}}
Copy link
Member

Choose a reason for hiding this comment

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

It is more straight forward and more "idiomatic" in react to set the length in pixels just as integers, and leave react to add the (px at the end).

Suggested change
style={{verticalAlign: 'middle', maxHeight: `${dimensions.height}px`, maxWidth: `${dimensions.width}px`}}
style={{verticalAlign: 'middle', maxHeight: dimensions.height, maxWidth: dimensions.width}}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i am 0/5 on this but that does not seem "idiomatic" to me. Explicit declaration seemed more natural.

Copy link
Contributor Author

@sudheerDev sudheerDev May 21, 2019

Choose a reason for hiding this comment

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

React used to add px to string as well and now apparently they don't do it anymore. Just wondering if they stop deciding to that with numbers we have to all change of these instances. I was checking few issues in react where devs are suggesting to remove this. I feel we should keep it explicit by adding them @jespino

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At least it is being considered for adding a warning to explicitly add units in dev env facebook/react#13567

Copy link
Member

Choose a reason for hiding this comment

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

I think the discussion goes more in the way of do not explicitly add "px" for every single number and only do it for certain css properties, like Width, Height, Border, Margin and Padding (and all its variants). I still prefer to use numbers right away, but probably makes sense to hear a third opinion here. @bradjcoughlin what do you think about it?

Copy link
Contributor

@bradjcoughlin bradjcoughlin May 22, 2019

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

What that says is actually the opposite of that. It says, if you need other unit than px you must specify it, if not, you can use a regular number, and add the exceptions lists to clarify where it doesn't auto include the px.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jespino right. Not sure why I negated that statement : )

Copy link
Contributor Author

@sudheerDev sudheerDev May 22, 2019

Choose a reason for hiding this comment

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

@jespino I feel this would be hard as we have to check for supported properties while programming as well as when reviewing making this harder than needed. Is your suggestion to at-least add it for obvious properties? Final thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

I think extra "thinking" is not needed. The approach is, if your unit is "px", you can use directly a number, if you need to specify the unit, you pass it explicitly. It will add the "px" for that properties where it makes sense, and leave as a number for the properties where it doesn't makes sense.

Copy link
Member

@jespino jespino left a comment

Choose a reason for hiding this comment

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

Proposed an improvement.

@sudheerDev sudheerDev changed the title MM-155703 certain aspect ratio of images cause pop on firefox MM-15709 certain aspect ratio of images cause pop on firefox May 21, 2019
@amyblais amyblais added CherryPick/Approved Meant for the quality or patch release tracked in the milestone and removed CherryPick/Candidate A candidate for a quality or patch release, but not yet approved labels May 21, 2019
@sudheerDev
Copy link
Contributor Author

@jespino @bradjcoughlin Changed the values to numbers. We kinda need this PR merged ASAP so QA can start testing few blocked tasks. We can continue with the discussion but can we go ahead with the PR if there are no functional changes required?. I can create a follow up PR if needed once we come to an agreement on the idiomatic way of doing this.

@sudheerDev sudheerDev added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core commiter labels May 22, 2019
@sudheerDev sudheerDev merged commit 0dab1a5 into mattermost:master May 22, 2019
@sudheerDev sudheerDev deleted the MM-15703 branch May 22, 2019 15:20
sudheerDev added a commit that referenced this pull request May 22, 2019
* MM-155703 certain aspect ratio of images cause pop on firefox

* Svg's need max dimention styles with px suffix

* remove string convertion and keep maxHeight and maxWidth as numbers
@sudheerDev sudheerDev added CherryPick/Done Successfully cherry-picked to the quality or patch release tracked in the milestone and removed CherryPick/Approved Meant for the quality or patch release tracked in the milestone labels May 22, 2019
@amyblais amyblais added Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation labels May 22, 2019
@ogi-m ogi-m added the Tests/Done Release tests have been written label May 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
4: Reviews Complete All reviewers have approved the pull request Changelog/Not Needed Does not require a changelog entry CherryPick/Done Successfully cherry-picked to the quality or patch release tracked in the milestone Docs/Not Needed Does not require documentation Tests/Done Release tests have been written
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants