backport SL-2318

This commit is contained in:
Cory LaViska
2025-01-02 10:02:10 -05:00
parent 2048df8a40
commit 89dd462720
2 changed files with 13 additions and 7 deletions

View File

@@ -14,6 +14,7 @@ During the alpha period, things might break! We take breaking changes very serio
# Next
- Improved performance of `<wa-select>` when using a large number of options
- Updated the Japanese translation
## 3.0.0-alpha.7

View File

@@ -36,6 +36,7 @@ export default class WaOption extends WebAwesomeElement {
// @ts-expect-error - Controller is currently unused
private readonly localize = new LocalizeController(this);
private isInitialized = false;
@query('.label') defaultSlot: HTMLSlotElement;
@@ -60,13 +61,17 @@ export default class WaOption extends WebAwesomeElement {
}
private handleDefaultSlotChange() {
// When the label changes, tell the controller to update
customElements.whenDefined('wa-select').then(() => {
const controller = this.closest('wa-select');
if (controller) {
controller.handleDefaultSlotChange();
}
});
if (this.isInitialized) {
// When the label changes, tell the controller to update
customElements.whenDefined('wa-select').then(() => {
const controller = this.closest('wa-select');
if (controller) {
controller.handleDefaultSlotChange();
}
});
} else {
this.isInitialized = true;
}
}
private handleMouseEnter() {