valor-software / ngx-bootstrap

Fast and reliable Bootstrap widgets in Angular (supports Ivy engine)
https://valor-software.com/ngx-bootstrap
MIT License
5.53k stars 1.69k forks source link

bug(rating): Rating component adds an extra star on mouse leave for decimal values #5076

Closed custompro12 closed 4 years ago

custompro12 commented 5 years ago

Bug description:

Binding a decimal value to the ngModel of a rating component will cause a star to be added to the component when the mouse leaves the component.

Plunker/StackBlitz that reproduces the issue:

1) Load stackblitz 2) Observe component correctly shows 2 stars for input value 2.1 3) Mouse over the component 4) Stop mouse over the component 5) Observe component now incorrectly shows 3 stars

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

Versions of ngx-bootstrap, Angular, and Bootstrap:

ngx-bootstrap: "^3.3.0",

Angular: "^7.2.5"

Bootstrap: "^4.2.1"

Build system: Angular CLI, System.js, webpack, starter seed:

Angular CLI

daniloff200 commented 4 years ago

Yeah, that looks like, if you used a 2.1, it will round up to 3, or, if it's 1.9, then, to 2

We need to Math.round(value) here

daniloff200 commented 4 years ago

so, for 2.1 it will be 2, but, for 2.5 -> 3