From c7ef8b6c24e6e413f053f71a0a61c96d856131cd Mon Sep 17 00:00:00 2001 From: Austin Burdine Date: Wed, 19 Aug 2015 23:39:07 -0400 Subject: [PATCH] fix auto width and height of spin button component refs #5652 - changes the spin-button so that it only sets the size when the button is submitting instead of all of the time --- core/client/app/components/gh-spin-button.js | 24 ++++++++----------- .../templates/components/gh-spin-button.hbs | 8 +++---- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/core/client/app/components/gh-spin-button.js b/core/client/app/components/gh-spin-button.js index ac9bb6f8d5..f487964c9c 100644 --- a/core/client/app/components/gh-spin-button.js +++ b/core/client/app/components/gh-spin-button.js @@ -4,6 +4,7 @@ export default Ember.Component.extend({ tagName: 'button', buttonText: '', submitting: false, + showSpinner: false, autoWidth: true, // Disable Button when isLoading equals true @@ -20,19 +21,14 @@ export default Ember.Component.extend({ return true; }, - setSize: function () { - if (!this.get('submitting') && this.get('autoWidth')) { - // this exists so that the spinner doesn't change the size of the button - this.$().width(this.$().width()); // sets width of button - this.$().height(this.$().height()); // sets height of button + setSize: Ember.observer('submitting', function () { + if (this.get('submitting') && this.get('autoWidth')) { + this.$().width(this.$().width()); + this.$().height(this.$().height()); + } else { + this.$().width(''); + this.$().height(''); } - }, - - width: Ember.observer('buttonText', 'autoWidth', function () { - this.setSize(); - }), - - didInsertElement: function () { - this.setSize(); - } + this.set('showSpinner', this.get('submitting')); + }) }); diff --git a/core/client/app/templates/components/gh-spin-button.hbs b/core/client/app/templates/components/gh-spin-button.hbs index a18aecf6da..eb93ed58a1 100644 --- a/core/client/app/templates/components/gh-spin-button.hbs +++ b/core/client/app/templates/components/gh-spin-button.hbs @@ -1,9 +1,9 @@ -{{#unless submitting}} +{{#if showSpinner}} + +{{else}} {{#if buttonText}} {{buttonText}} {{else}} {{{yield}}} {{/if}} -{{else}} - -{{/unless}} +{{/if}} \ No newline at end of file