fix(select): setting options async updates rendered text (#26667)

resolves #19324
This commit is contained in:
Liam DeBeasi
2023-01-25 13:30:03 -05:00
committed by GitHub
parent a4ceda8a95
commit a687457936
3 changed files with 28 additions and 11 deletions

View File

@ -1,5 +1,5 @@
import type { ComponentInterface, EventEmitter } from '@stencil/core';
import { Component, Element, Event, Host, Method, Prop, State, Watch, h } from '@stencil/core';
import { Component, Element, Event, Host, Method, Prop, State, Watch, h, forceUpdate } from '@stencil/core';
import { getIonMode } from '../../global/ionic-global';
import type {
@ -166,6 +166,14 @@ export class Select implements ComponentInterface {
this.mutationO = watchForOptions<HTMLIonSelectOptionElement>(this.el, 'ion-select-option', async () => {
this.updateOverlayOptions();
/**
* We need to re-render the component
* because one of the new ion-select-option
* elements may match the value. In this case,
* the rendered selected text should be updated.
*/
forceUpdate(this);
});
}