mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-16 01:52:19 +08:00
fix(vue): ensure v-model value is properly synced before ionChange event (#22749)
resolves #22610
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user