@@ -10,11 +10,12 @@ import {
1010 hasCSSTransform ,
1111 onBeforeUpdate ,
1212 onUpdated ,
13+ queuePostFlushCb ,
1314 resolveTransitionProps ,
1415 useTransitionState ,
1516 warn ,
1617} from '@vue/runtime-dom'
17- import { extend , isArray } from '@vue/shared'
18+ import { extend , invokeArrayFns , isArray } from '@vue/shared'
1819import {
1920 type Block ,
2021 type TransitionBlock ,
@@ -126,17 +127,22 @@ export const VaporTransitionGroup: ObjectVaporComponent = decorate({
126127 props : cssTransitionProps ,
127128 state,
128129 instance,
130+ group : true ,
129131 } as VaporTransitionHooks )
130132
131133 children = getTransitionBlocks ( slottedBlock )
132134 for ( let i = 0 ; i < children . length ; i ++ ) {
133135 const child = children [ i ]
134136 if ( isValidTransitionBlock ( child ) ) {
135137 if ( child . $key != null ) {
136- setTransitionHooks (
138+ const hooks = resolveTransitionHooks (
137139 child ,
138- resolveTransitionHooks ( child , cssTransitionProps , state , instance ! ) ,
140+ cssTransitionProps ,
141+ state ,
142+ instance ! ,
139143 )
144+ hooks . group = true
145+ setTransitionHooks ( child , hooks )
140146 } else if ( __DEV__ && child . $key == null ) {
141147 warn ( `<transition-group> children must be keyed` )
142148 }
@@ -221,3 +227,23 @@ function getFirstConnectedChild(
221227 if ( el . isConnected ) return el
222228 }
223229}
230+
231+ /**
232+ * The implementation of TransitionGroup relies on the onBeforeUpdate and onUpdated hooks.
233+ * However, when the slot content of TransitionGroup updates, it does not trigger the
234+ * onBeforeUpdate and onUpdated hooks. Therefore, it is necessary to manually trigger
235+ * the TransitionGroup update hooks to ensure its proper work.
236+ */
237+ export function triggerTransitionGroupUpdate (
238+ transition : VaporTransitionHooks ,
239+ ) : void {
240+ const { instance } = transition
241+ if ( ! instance . isUpdating ) {
242+ instance . isUpdating = true
243+ if ( instance . bu ) invokeArrayFns ( instance . bu )
244+ queuePostFlushCb ( ( ) => {
245+ instance . isUpdating = false
246+ if ( instance . u ) invokeArrayFns ( instance . u )
247+ } )
248+ }
249+ }
0 commit comments