Fixes #606 #610
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix-606"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #606.
If there are no subviews in
UIView
, yoga assumes thatsizeThatFits:
returnsCGSizeZero
. However, according to the documentation,UIView
returns current size if there are no subviews.This diff adds a check - if there are no subviews,
sizeThatFits:
doesn't get called, and CGSizeZero is returned.Looks good! Would you mind adding a unit test before we ship it?
Thanks!
@dshahidehpour sure! One question: I'm trying to run tests with
but I get an error:
How do I fix that? Or is there an alternative way of running tests?
Yeah, you can open the Xcode workspace and run them that way
Implemented tests. There's a problem on travis ci, but master is also failing.
@dshahidehpour gentle ping on this one. Could you please have a look?
why do we have to check it's a
UIView
or not?Because the other classes (like UILabel) return correct size for sizeThatFits if there are no subviews
I wonder if there is a cleaner way to do this...I don't want us to check the class of a view every time yoga measures it.
Do you have ideas by any chance? The problem is that it seems that it's only UIView that results in this "odd" behavior - returns current size when it's empty.
An option could be to create a flag
isUIView
inYGLayout
and initialize it ininitWithView:
. What would you say?I like it! Lets give it a shot.
@dshahidehpour gentle ping. Could you please have a look?
Hey @dshahidehpour any news on this one?
Sorry @kovpas, I haven't had the bandwidth to merge this. Maybe @emilsjolander could help?
I'll try ASAP
Hey, @dshahidehpour! Just wondering if there's any progress on the review?
Hey @kovpas I'm really sorry for the delay. I've moved onto a different project at FB, so I'm finding a new POC who will be able to attend to your PRs in a much more timely fashion, stay-tuned!
Thanks @dshahidehpour, and good luck with a new project! 👍
Hey @dshahidehpour any news on that? Could you please point me to a person, who could merge the pull request?
Thanks for approving @matthargett! Could you please also merge the PR? I don’t have rights to do that.
Here the
view
passed in the initialiser is of typeUIView
. Why do we need to have a bool with[view isMemberOfClass:[UIView class]]
variable?@@ -304,10 +306,19 @@ static YGSize YGMeasureView(
const CGFloat constrainedHeight = (heightMode == YGMeasureModeUndefined) ? CGFLOAT_MAX: height;
Instead of pointing to the issue. Can you comment in the code, why this check is added.
@@ -304,10 +306,19 @@ static YGSize YGMeasureView(
const CGFloat constrainedHeight = (heightMode == YGMeasureModeUndefined) ? CGFLOAT_MAX: height;
I think
!view.yoga.isUIView
this check is not required. Happy to hear about your inputsThanks for the PR. I have written few review comments
Because it could also be a
UILabel
,UIButton
and any other subclass ofUIView
.isMemberOfClass:
makes sure that theview
parameter is exactlyUIView
, not a subclass.@@ -304,10 +306,19 @@ static YGSize YGMeasureView(
const CGFloat constrainedHeight = (heightMode == YGMeasureModeUndefined) ? CGFLOAT_MAX: height;
this condition practically says "we want to invoke
sizeThatFits
only in case if the measured view is not aUIView
instance or it's aUIView
, but has got children". The check is needed because we do want to invokesizeThatFits
for a UILabel (for example) that has got no subviews, but returns a correct value as a result of invocation ofsizeThatFits
@@ -304,10 +306,19 @@ static YGSize YGMeasureView(
const CGFloat constrainedHeight = (heightMode == YGMeasureModeUndefined) ? CGFLOAT_MAX: height;
Done.
@@ -304,10 +306,19 @@ static YGSize YGMeasureView(
const CGFloat constrainedHeight = (heightMode == YGMeasureModeUndefined) ? CGFLOAT_MAX: height;
Aah Got it. Can you add a comment(in brief) explaining this before the condition?
@priteshrnandgaonkar thanks for the comments. Addressed all of them.
@@ -304,10 +306,19 @@ static YGSize YGMeasureView(
const CGFloat constrainedHeight = (heightMode == YGMeasureModeUndefined) ? CGFLOAT_MAX: height;
Done
@priteshrnandgaonkar has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Is there still anything holding this off from being merged?
priteshrnandgaonkar has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Pull request closed