Skip to content

Commit 2a5c7db

Browse files
authored
fix(ui5-ai-button): reset button width after animations (#9923)
Previously, we had an issue where the AIButton's text was not fully visible when changing states while hidden. This was happening because the button's width was being set to 0px after the fade-out animation (since the button was hidden). We addressed that issue by resetting the button's width style after the animations are complete, ensuring that the button has the correct width based on its state, regardless of whether it is hidden.
1 parent fe1d816 commit 2a5c7db

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/ai/src/Button.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class Button extends UI5Element {
152152
async _fadeOut(): Promise<void> {
153153
const fadeOutDuration = 180;
154154

155-
const button = this.shadowRoot?.querySelector("[ui5-button]") as MainButton;
155+
const button = this._mainButton;
156156
const newStateObject = this._effectiveStateObject;
157157

158158
if (!newStateObject) {
@@ -204,6 +204,12 @@ class Button extends UI5Element {
204204
this.fadeMid = false;
205205
this.fadeIn = false;
206206
}, fadeResetDuration);
207+
208+
// reset the button's width after animations
209+
const button = this._mainButton;
210+
if (button) {
211+
button.style.width = "";
212+
}
207213
}
208214

209215
/**
@@ -215,6 +221,10 @@ class Button extends UI5Element {
215221
this.fireDecoratorEvent("click");
216222
}
217223

224+
get _mainButton() {
225+
return this.shadowRoot?.querySelector("[ui5-button]") as MainButton;
226+
}
227+
218228
get _effectiveState() {
219229
return this.state || (this.states.length && this.states[0].name) || "";
220230
}

0 commit comments

Comments
 (0)