Skip to content

Commit

Permalink
The button now gets re-enabled after the callback is finished.
Browse files Browse the repository at this point in the history
  • Loading branch information
cesarParra committed Nov 3, 2023
1 parent fb9f3a1 commit 66be686
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,26 @@ export default class BaseButton extends NavigationMixin(TwElement) {
e.preventDefault();
e.stopPropagation();

// TODO: This needs to be more robust because it doesn't work for refresh
// and also doesn't work if the validation fails on a submit.
this.disabled = true;

if (this.action.type === 'submit') {
const evt = new CustomEvent('submit',
{
bubbles: true,
detail: {action: execute, fnReference: this.action.src, callback: this.actionCallback},
detail: {
action: execute, fnReference: this.action.src, callback: () => {
this.actionCallback();
this.disabled = false;
}
},
composed: true
});
this.dispatchEvent(evt);
} else if (this.action.type === "action") {
try {
const result = await execute({fnReference: this.action.src});
this.actionCallback(result);
this.disabled = false;
} catch (e) {
console.error(e);
}
Expand Down

0 comments on commit 66be686

Please sign in to comment.