From 7878a60bf80e77668e25fc224aed1717079fe73a Mon Sep 17 00:00:00 2001 From: pk Date: Fri, 2 May 2025 22:47:16 +0200 Subject: [PATCH] Make sure the button's shadowdom is ready before starting any animations. --- package.json | 2 +- tp-button.js | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index a9fdbbe..76c8c54 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tp/tp-button", - "version": "1.3.0", + "version": "1.3.2", "description": "", "main": "tp-button.js", "scripts": { diff --git a/tp-button.js b/tp-button.js index 560325a..bb820da 100644 --- a/tp-button.js +++ b/tp-button.js @@ -1,6 +1,6 @@ /** @license -Copyright (c) 2022 trading_peter +Copyright (c) 2025 trading_peter This program is available under Apache License Version 2.0 */ @@ -234,6 +234,8 @@ class TpButton extends EventHelpers(LitElement) { return; } + await this.updateComplete; + if (this._isAnimating) { this._queue.push('showSuccess'); return; @@ -253,6 +255,8 @@ class TpButton extends EventHelpers(LitElement) { return; } + await this.updateComplete; + if (this._isAnimating) { this._queue.push('showError'); return; @@ -266,12 +270,14 @@ class TpButton extends EventHelpers(LitElement) { this.locked = false; } - showSpinner() { + async showSpinner() { if (!this.extended) { console.warn(this.tagName + ': Is not in extended mode!'); return; } + await this.updateComplete; + if (this._isAnimating) { this._queue.push('showSpinner'); return;