fix(vue): ensure v-model value is properly synced before ionChange event (#22749)

resolves #22610
This commit is contained in:
Liam DeBeasi
2021-01-13 11:22:27 -05:00
committed by GitHub
parent 348c50b7ea
commit e1d6627bf0
3 changed files with 20 additions and 9 deletions

View File

@ -57,6 +57,17 @@ export const defineContainer = <Props>(name: string, componentProps: string[] =
vnode.el.addEventListener(modelUpdateEvent.toLowerCase(), (e: Event) => {
modelPropValue = (e?.target as any)[modelProp];
emit(UPDATE_VALUE_EVENT, modelPropValue);
/**
* We need to emit the change event here
* rather than on the web component to ensure
* that any v-model bindings have been updated.
* Otherwise, the developer will listen on the
* native web component, but the v-model will
* not have been updated yet.
*/
emit(modelUpdateEvent, e);
e.stopImmediatePropagation();
});
}
};
@ -119,7 +130,7 @@ export const defineContainer = <Props>(name: string, componentProps: string[] =
Container.props = [...componentProps, ROUTER_LINK_VALUE];
if (modelProp) {
Container.props.push(MODEL_VALUE);
Container.emits = [UPDATE_VALUE_EVENT];
Container.emits = [UPDATE_VALUE_EVENT, modelUpdateEvent];
}
return Container;