Skip to content
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

fix(fxFlex): prevent setting min/max-size when grow/shrink is zero #160

Merged
merged 1 commit into from
Feb 9, 2017

Conversation

somombo
Copy link
Contributor

@somombo somombo commented Feb 7, 2017

handle various scenarios of grow/shrink being zero:

  • set min-width/min-height only if grow != 0
  • set max-width/max-height only if shink != 0
  • set both min and max if both grow == 0 AND shink == 0
  • add tests for these scenarios
  • remove max-width from test "should set a min-width when the shrink == 0"

fixes #153

Signed-off-by: Somo somo@mombo.solutions

@joshwiens
Copy link
Contributor

@somombo
Copy link
Contributor Author

somombo commented Feb 7, 2017

@d3viant0ne i'm on it, had forgotten to run the linter

@somombo somombo force-pushed the somombo/issue153_maxmin_patch branch from faf3087 to f5409eb Compare February 7, 2017 01:00
Copy link
Contributor

@ThomasBurleson ThomasBurleson left a comment

Choose a reason for hiding this comment

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

Code formatting/logic change.

@@ -301,8 +311,21 @@ export class FlexDirective extends BaseFxDirective implements OnInit, OnChanges,
let usingCalc = String(basis).indexOf('calc') > -1;
let isPx = String(basis).indexOf('px') > -1 || usingCalc;

css[min] = (basis == '0%') ? 0 : isPx ? basis : null;
css[max] = (basis == '0%') ? 0 : usingCalc ? null : basis;
Copy link
Contributor

Choose a reason for hiding this comment

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

Plz use this:

     // if shrink and grow are both zero then make box inflexible
     //  - should not set a min when the grow is zero
     //  - should not set a max when the shrink is zero
     let isFixed = !grow && !shrink;
     css[min] = (basis == '0%') ? 0 : isFixed || (isPx && grow) ? basis : null;
     css[max] = (basis == '0%') ? 0 : isFixed || (!usingCalc && shrink) ? basis : null;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.
Though it does look a bit awkward.

No Problem.
Thanks for looking over so quick.

Copy link
Contributor

@joshwiens joshwiens Feb 7, 2017

Choose a reason for hiding this comment

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

That's honestly a matter of perspective. You can get a lot evaluated, very concisely using a ternary and usually on a single line.

Once you get used to scanning it, the if ( ) conditions start to become a bit tedious to read / write.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, as long we get to a place where #153 and things stemming from it are resolved. I really done care much about the minor details..

Thanks for all the feadback!

@somombo somombo force-pushed the somombo/issue153_maxmin_patch branch from f5409eb to b8b5d1c Compare February 7, 2017 01:38
@ThomasBurleson
Copy link
Contributor

ThomasBurleson commented Feb 7, 2017

@somombo - just an FYI that you will need to rebase your PR tomorrow after #158 is merged into master. At that point I can finish testing your PR and update to presubmit-for-merge.

From a code perspective, these changes look good. Testing with the demos will reveal any issues.

Thx for your efforts on this PR.

@somombo
Copy link
Contributor Author

somombo commented Feb 7, 2017

@ThomasBurleson - Yeah, no problem! I tested with demos and everthing looked identical to before.

By the way, none of the demos exemplify usage of something like 1 0 123px or 0 1 123px. It may not be a bad idea to provide such examples in future.

@ThomasBurleson
Copy link
Contributor

ThomasBurleson commented Feb 7, 2017

@somombo - want to prepare a cool demo that highlights why your changes are useful ? That would be a great addition to this PR IMO.

@somombo
Copy link
Contributor Author

somombo commented Feb 7, 2017

@ThomasBurleson this is now rebased

@ThomasBurleson
Copy link
Contributor

@somombo - Can you squash plz. Your change list looks huge for some reason.

@somombo
Copy link
Contributor Author

somombo commented Feb 7, 2017

@ThomasBurleson could you post the commit hashes for the extraneous commits just so i know which ones you're referring to?

@googlebot
Copy link
Collaborator

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that they're okay with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

@googlebot googlebot added cla: no PR author needs to sign Google's CLA: https://opensource.google.com/docs/cla/ and removed cla: yes labels Feb 7, 2017
@somombo
Copy link
Contributor Author

somombo commented Feb 7, 2017

(@googlebot) I had changed my cla and my git email to somo@mombo.solutions for consistency. That someone was me in both cases

@ThomasBurleson
Copy link
Contributor

@somombo - Your change list appears to include this commit SHA dad69fe that is already in master.

@somombo
Copy link
Contributor Author

somombo commented Feb 7, 2017

@ThomasBurleson Okay I see what you are referring to now.. I'm not sure how to fix that, kindly advise

@ThomasBurleson
Copy link
Contributor

ThomasBurleson commented Feb 7, 2017

try:

git co somombo/issue153_maxmin_patch;
git pull --rebase upstream master;
git push -f origin somombo/issue153_maxmin_patch

This assume you have registered upstream as a remote branch to https://github.com/angular/flex-layout.git

@somombo
Copy link
Contributor Author

somombo commented Feb 7, 2017

@ThomasBurleson Appears to not have done anything. Here is what I got for those three commands respectively:

Already on 'somombo/issue153_maxmin_patch'
Current branch somombo/issue153_maxmin_patch is up to date.
Everything up-to-date

@ThomasBurleson
Copy link
Contributor

ThomasBurleson commented Feb 8, 2017

@somombo - do this:

  • get rebase -i HEAD~3,
  • then d to remove the commit dad69fe
  • then exit and save
  • get push -f origin issue153_maxmin_patch

@somombo somombo force-pushed the somombo/issue153_maxmin_patch branch from 76e8bc2 to b09eff2 Compare February 8, 2017 08:37
@googlebot
Copy link
Collaborator

CLAs look good, thanks!

@googlebot googlebot removed the cla: no PR author needs to sign Google's CLA: https://opensource.google.com/docs/cla/ label Feb 8, 2017
@ThomasBurleson ThomasBurleson added pr: lgtm This PR has been approved by the reviewer pr: needs presubmit and removed cla: no PR author needs to sign Google's CLA: https://opensource.google.com/docs/cla/ in-progress pr: needs rebase labels Feb 8, 2017
@ThomasBurleson
Copy link
Contributor

@somombo - I added you as a contributor to this repository.

Future PRs should be based on branch from this PR; which allows the core team easier access to your changes.

@ThomasBurleson
Copy link
Contributor

@here - CLA was signed.

@somombo
Copy link
Contributor Author

somombo commented Feb 8, 2017

@ThomasBurleson Thanks! I appreciate it..

Does that mean for future PRs n patches, I should just work with the master branch on my fork.. rather than creating a somombo/... branch ?

@somombo somombo closed this Feb 8, 2017
@somombo
Copy link
Contributor Author

somombo commented Feb 8, 2017

@here sorry accidentally hit the "close pull request" button instead of the comment button

@ThomasBurleson
Copy link
Contributor

@somombo - apologies, but a recent merge to master requires yet another rebase to this PR.

@googlebot googlebot added the cla: no PR author needs to sign Google's CLA: https://opensource.google.com/docs/cla/ label Feb 9, 2017
handle various scenarios of grow/shrink being zero:
*  set `min-width`/`min-height` only if `grow != 0`
*  set `max-width`/`max-height` only if `shink != 0`
*  set both min and max if both `grow == 0` AND `shink == 0`
*  add tests for these scenarios
*  remove max-width from  test "should set a min-width when the shrink == 0"

fixes angular#153

Signed-off-by: Somo <somo@mombo.solutions>
@somombo somombo force-pushed the somombo/issue153_maxmin_patch branch from 028cf4b to 830b968 Compare February 9, 2017 00:19
@googlebot
Copy link
Collaborator

CLAs look good, thanks!

@googlebot googlebot added cla: yes and removed cla: no PR author needs to sign Google's CLA: https://opensource.google.com/docs/cla/ labels Feb 9, 2017
@somombo
Copy link
Contributor Author

somombo commented Feb 9, 2017

@ThomasBurleson is this good?

@somombo
Copy link
Contributor Author

somombo commented Feb 9, 2017

@ThomasBurleson so what do I do next, do I hit the "squash and merge" or the "rebase and merge" button?

@ThomasBurleson
Copy link
Contributor

ThomasBurleson commented Feb 9, 2017

@somombo - you should NEVER hit the Merge button(s). That is for the Core Team Admins only.

I will start the presubmit testing and merge process. THx

@tinayuangao tinayuangao merged commit 942939e into angular:master Feb 9, 2017
@somombo
Copy link
Contributor Author

somombo commented Feb 9, 2017

@ThomasBurleson I figured if there was something I wasn't supposed to do, the system would be set up so I wouldn't be able to do it.. but wasn't sure so good thing I asked :)

@ThomasBurleson
Copy link
Contributor

@somombo - master is protected and accessible only to admins. you have write capabilities so you can create branches and update issues, assign labels, etc.. Just do not merge ;-).

karlhaas pushed a commit to karlhaas/flex-layout that referenced this pull request May 3, 2017
…ngular#160)

handle various scenarios of grow/shrink being zero:
*  set `min-width`/`min-height` only if `grow != 0`
*  set `max-width`/`max-height` only if `shink != 0`
*  set both min and max if both `grow == 0` AND `shink == 0`
*  add tests for these scenarios
*  remove max-width from  test "should set a min-width when the shrink == 0"

fixes angular#153

Signed-off-by: Somo <somo@mombo.solutions>
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes pr: lgtm This PR has been approved by the reviewer pr: needs presubmit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(fxFlex): zero value for Shrink xor Grow results in overflowing content when basis is px
5 participants