Fomantic-UI icon indicating copy to clipboard operation
Fomantic-UI copied to clipboard

[Progress] onSuccess trigger only the first time when value is set to 0 to 100%

Open dutrieux opened this issue 3 years ago • 6 comments

Bug Report

onSuccess event is trigger only the first time when value is set to 0 (reset) to 100%

Steps to reproduce

  1. click on reset button
  2. click on 100% button
  3. check the console, the onSuccess event is trigger
  4. click on reset button
  5. click on 100% button
  6. 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)

progress gif

Version

2.8.8

dutrieux avatar Dec 12 '21 14:12 dutrieux

Fixed by #2178 See your adjusted jsfiddle here https://jsfiddle.net/lubber/aqb5zjuo/

lubber-de avatar Dec 12 '21 17:12 lubber-de

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 avatar Jun 16 '22 11:06 grandeljay

@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

lubber-de avatar Jun 16 '22 17:06 lubber-de

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.

grandeljay avatar Jun 17 '22 05:06 grandeljay

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 avatar Jun 17 '22 08:06 grandeljay

@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/

lubber-de avatar Jun 17 '22 20:06 lubber-de