johannesjo / angular2-promise-buttons

Chilled loading buttons for angular2
https://johannesjo.github.io/angular2-promise-buttons/#demo
MIT License
86 stars 28 forks source link

Fix: init Loading State when promise is passed after click #14

Closed ghost closed 7 years ago

ghost commented 7 years ago

In pull request https://github.com/johannesjo/angular2-promise-buttons/pull/12 I broke something :-( This PR fixes the bug and and I added a test for this use-case.

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 94.309% when pulling a97fb9d6de5e1eaa1dbdff314322f1f88fe4dd96 on maxkorz:fix-promise-after-click into 6d0d12a3cc47b1c3b2373450dcc914da95bc57be on johannesjo:master.

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 94.309% when pulling 56bcd98fab13a320d7e26776b64fe5122e4a8f26 on maxkorz:fix-promise-after-click into 6d0d12a3cc47b1c3b2373450dcc914da95bc57be on johannesjo:master.

ghost commented 7 years ago

I couldn't fix the test completely. That's very strange.

When I do $event.preventDefault(); in handleCurrentBtnOnly:

  1. I can't click on the "Submit" button in the "Inside a form" section in the demo
  2. The test fails

but, when I do return false in handleCurrentBtnOnly:

  1. I can't click on the "Submit" button in the demo
  2. The test passes

Sadly, I have no idea how to make the test work for the return false case. If you have no idea how to make the test handle return false case, you can merge the PR, the issue is fixed.

The best I can do is make sure that handleCurrentBtnOnly doesn't return false

johannesjo commented 7 years ago

Thanks for the PR. I'll try to check everything again later this week.