File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
packages/core/ui/transition Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -262,9 +262,22 @@ export class PageTransition extends Transition {
262262 newFragment . setSharedElementEnterTransition ( transitionSet ) ;
263263 newFragment . setSharedElementReturnTransition ( transitionSet ) ;
264264
265+ // Guard against duplicate shared element names being added to the same transaction
266+ const addedSharedElementNames = new Set ( ) ;
265267 presenting . forEach ( ( v ) => {
268+ const name = v ?. sharedTransitionTag ;
269+ const nativeView = v ?. nativeView ;
270+ if ( ! name || ! nativeView || addedSharedElementNames . has ( name ) ) {
271+ // prevent duplicates or invalid items
272+ return ;
273+ }
266274 setTransitionName ( v ) ;
267- fragmentTransaction . addSharedElement ( v . nativeView , v . sharedTransitionTag ) ;
275+ try {
276+ fragmentTransaction . addSharedElement ( nativeView , name ) ;
277+ addedSharedElementNames . add ( name ) ;
278+ } catch ( err ) {
279+ // ignore duplicates or issues adding shared element to avoid crashing
280+ }
268281 } ) ;
269282 if ( toPage . isLoaded ) {
270283 onPageLoaded ( ) ;
You can’t perform that action at this time.
0 commit comments