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

Better handling for progress bar with max=0 #3386

Closed
devoto13 opened this issue Sep 30, 2019 · 5 comments · Fixed by #3400
Closed

Better handling for progress bar with max=0 #3386

devoto13 opened this issue Sep 30, 2019 · 5 comments · Fixed by #3400

Comments

@devoto13
Copy link
Contributor

Bug description:

Currently progress bar with the max value of 0 fills for the width necessary for the label to display. This is not consistent behavior and it will be better to make max=0 a special case and always fill either 0% or 100%.

I think 100% will be a more sensible behavior because of cases like value=42 and max=0. In this case progress bar will trim value to 0, but 100% will make some sense in this situation unlike 0%.

Link to minimally-working StackBlitz that reproduces the issue:

https://stackblitz.com/edit/angular-mc1mw9

Versions of Angular, ng-bootstrap and Bootstrap:

Angular: 8.2.0

ng-bootstrap: 5.1.0

Bootstrap: 4.3.1

@maxokorokov
Copy link
Member

maxokorokov commented Oct 4, 2019

Currently progress bar with the max value of 0 fills for the width necessary for the label to display

Well, from what I see style="width: ..." is not set at all when max === 0 → this looks like a bug and should be fixed. Works fine for negative values.

@devoto13
Copy link
Contributor Author

devoto13 commented Oct 4, 2019

The real question is what value should be displayed in this case.
It may be as well worth throwing the error when max=0 as a not intended usage of the component.

@maxokorokov
Copy link
Member

I don't think it should fail with an error, it should just render the component correctly.

What's wrong with having max === 0? When max is 0, you just can't go beyond 0. Looks pretty consistent to me.

This issue from my point of view is that:

[value]="10" [max]="0" [showValue]="true"

Gives:
Screen Shot 2019-10-04 at 14 24 31

  • NaN instead of 0
  • doesn't apply style="width:..."

Let's discuss changing default behaviour in #3390

@maxokorokov
Copy link
Member

Also should update the docs, saying that max SHOULD be a positive value

@maxokorokov
Copy link
Member

maxokorokov commented Oct 17, 2019

Ok, on reflection and playing with standard <progress>, I think we should do same thing it does and fallback max to default value which is 100 in bootstrap.

Left a comment in the review: #3400 (review)

@maxokorokov maxokorokov added this to the 5.1.2 milestone Oct 17, 2019
@maxokorokov maxokorokov modified the milestones: 5.1.2, 5.1.3 Oct 24, 2019
chrstnbrn added a commit to chrstnbrn/ng-bootstrap that referenced this issue Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants