Skip to content

Commit

Permalink
iaux-userlist-settings: disable save button on modal on click, re-ena…
Browse files Browse the repository at this point in the history
…ble if error happens (#875)
  • Loading branch information
iisa authored Oct 17, 2023
1 parent 91f2d00 commit 339e2a8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/ia-userlist-settings/src/ia-user-list-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export class IAUserListSettings extends LitElement {

private async saveListDetails(event: Event) {
event.preventDefault();
const submitButton = (event.target as HTMLElement)?.querySelector('button#save-list-settings');
submitButton?.setAttribute('disabled', 'true');

try {
const userListData: UserListOptions = {
Expand Down Expand Up @@ -74,11 +76,13 @@ export class IAUserListSettings extends LitElement {
})
);
console.log('error', error);
submitButton?.removeAttribute('disabled');
}
}

private emitCloseModalEvent() {
this.dispatchEvent(new CustomEvent('listModalClosed'));
private emitCloseModalEvent(e: Event) {
e.preventDefault();
this.dispatchEvent(new Event('listModalClosed'));
}

render() {
Expand Down Expand Up @@ -119,7 +123,7 @@ export class IAUserListSettings extends LitElement {
>
Cancel
</button>
<button type="submit" class="ia-button primary">Save</button>
<button type="submit" id="save-list-settings" class="ia-button primary">Save</button>
</div>
</form>
</section>
Expand Down

0 comments on commit 339e2a8

Please sign in to comment.