mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-01 10:12:45 +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.setSharedElementEnterTransition(transitionSet);
|
||||||
newFragment.setSharedElementReturnTransition(transitionSet);
|
newFragment.setSharedElementReturnTransition(transitionSet);
|
||||||
|
|
||||||
|
// Guard against duplicate shared element names being added to the same transaction
|
||||||
|
const addedSharedElementNames = new Set();
|
||||||
presenting.forEach((v) => {
|
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);
|
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) {
|
if (toPage.isLoaded) {
|
||||||
onPageLoaded();
|
onPageLoaded();
|
||||||
|
|||||||
Reference in New Issue
Block a user