Fomantic-UI
Fomantic-UI copied to clipboard
[Progress] onSuccess trigger only the first time when value is set to 0 to 100%
Bug Report
onSuccess event is trigger only the first time when value is set to 0 (reset) to 100%
Steps to reproduce
- click on reset button
- click on 100% button
- check the console, the onSuccess event is trigger
- click on reset button
- click on 100% button
- check the console, the onSuccess event is not trigger
Expected result
onSuccess trigger everytime value is set to 0 to 100%
Actual result
onSuccess trigger only the first time when value is set to 0 to 100%
Testcase
https://jsfiddle.net/dutrieux/v85om3t1/
Screenshot (if possible)
Version
2.8.8
Fixed by #2178 See your adjusted jsfiddle here https://jsfiddle.net/lubber/aqb5zjuo/
I am using v2.9.0-beta.293
and also just noticed this. @lubber-de can you please double check it's still working?
@grandeljay 🤔 Still working for me using the latest nightly build See https://jsfiddle.net/lubber/9xamt3je/1/
- click on reset button
- click on 100% button
- check the console, the onSuccess event is triggered
- click on reset button
- click on 100% button
- check the console, the onSuccess event is triggered again
Thanks for checking and sorry about all the noise! My code must be wrong, I'll get back to you if I am able to replicate the behaviour I am experiencing.
As mentioned, I wasn't able to achieve this behaviour in a fiddle but I would still like to share some of the output I am getting, maybe you have an idea why?
Code:
progress.progress('increment', 1);
console.log('get percent: ' + progress.progress('get percent'));
console.log('get value: ' + progress.progress('get value'));
console.log('get total: ' + progress.progress('get total'));
console.log('is complete: ' + progress.progress('is complete'));
console.log('is success: ' + progress.progress('is success'));
Output:
get percent: 100
get value: 1
get total: 1
is complete: false
is success: false
How can percent
be 100
and is complete
be false
?
@grandeljay That's because the bar is animated and the completion state is changed when the animation ends. So if you immediatly call "is complete" right after "increment", the animation has not ended yet, so the state has not been changed to "complete". That's the reason you should use the "on" callbacks instead. To make your example work nevertheless, wrap the console.logs into a delayed timeout function. See https://jsfiddle.net/lubber/w3qd58ma/15/