File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
packages/vue/src/vue-component-lib Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -91,8 +91,17 @@ export const defineContainer = <Props, VModelType = string | number | boolean>(
91
91
const eventsNames = Array . isArray ( modelUpdateEvent ) ? modelUpdateEvent : [ modelUpdateEvent ] ;
92
92
eventsNames . forEach ( ( eventName : string ) => {
93
93
el . addEventListener ( eventName . toLowerCase ( ) , ( e : Event ) => {
94
- modelPropValue = ( e ?. target as any ) [ modelProp ] ;
95
- emit ( UPDATE_VALUE_EVENT , modelPropValue ) ;
94
+ /**
95
+ * Only update the v-model binding if the event's target is the element we are
96
+ * listening on. For example, Component A could emit ionChange, but it could also
97
+ * have a descendant Component B that also emits ionChange. We only want to update
98
+ * the v-model for Component A when ionChange originates from that element and not
99
+ * when ionChange bubbles up from Component B.
100
+ */
101
+ if ( e . target . tagName === el . tagName ) {
102
+ modelPropValue = ( e ?. target as any ) [ modelProp ] ;
103
+ emit ( UPDATE_VALUE_EVENT , modelPropValue ) ;
104
+ }
96
105
} ) ;
97
106
} ) ;
98
107
} ,
You can’t perform that action at this time.
0 commit comments