mirror of
				https://github.com/NativeScript/NativeScript.git
				synced 2025-10-31 16:06:01 +08:00 
			
		
		
		
	fix(android): shared element with target name already added to transaction (#10793)
This commit is contained in:
		| @ -262,9 +262,22 @@ export class PageTransition extends Transition { | ||||
| 		newFragment.setSharedElementEnterTransition(transitionSet); | ||||
| 		newFragment.setSharedElementReturnTransition(transitionSet); | ||||
|  | ||||
| 		// Guard against duplicate shared element names being added to the same transaction | ||||
| 		const addedSharedElementNames = new Set(); | ||||
| 		presenting.forEach((v) => { | ||||
| 			const name = v?.sharedTransitionTag; | ||||
| 			const nativeView = v?.nativeView; | ||||
| 			if (!name || !nativeView || addedSharedElementNames.has(name)) { | ||||
| 				// prevent duplicates or invalid items | ||||
| 				return; | ||||
| 			} | ||||
| 			setTransitionName(v); | ||||
| 			fragmentTransaction.addSharedElement(v.nativeView, v.sharedTransitionTag); | ||||
| 			try { | ||||
| 				fragmentTransaction.addSharedElement(nativeView, name); | ||||
| 				addedSharedElementNames.add(name); | ||||
| 			} catch (err) { | ||||
| 				// ignore duplicates or issues adding shared element to avoid crashing | ||||
| 			} | ||||
| 		}); | ||||
| 		if (toPage.isLoaded) { | ||||
| 			onPageLoaded(); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Nathan Walker
					Nathan Walker