Skip to content
TypeScript

fix(mobile): preserve the final composer animation frame (#11114)

Julius Marminge96f43708a0ec
diff --git a/apps/mobile/package.json b/apps/mobile/package.json
index d5285f263fd..a5d2f40b4a9 100644
--- a/apps/mobile/package.json
+++ b/apps/mobile/package.json
@@ -147,6 +147,7 @@
"buildFromSource": [
"expo-notifications",
"react-native-screens",
+ "react-native-reanimated",
"@react-native-menu/menu",
"expo-audio"
]
diff --git a/apps/mobile/src/components/ComposerAttachmentButton.tsx b/apps/mobile/src/components/ComposerAttachmentButton.tsx
index 1af72d8883d..8ea70a45c02 100644
--- a/apps/mobile/src/components/ComposerAttachmentButton.tsx
+++ b/apps/mobile/src/components/ComposerAttachmentButton.tsx
@@ -40,6 +40,9 @@ export function ComposerAttachmentButton(props: {
return (
<ControlPillMenu
+ accessible
+ accessibilityLabel="Add attachment"
+ accessibilityRole="button"
actions={ATTACHMENT_MENU_ACTIONS}
onPressAction={({ nativeEvent }) => {
if (nativeEvent.event === "photos") {
diff --git a/patches/[email protected] b/patches/[email protected]
new file mode 100644
index 00000000000..6bf44826d4f
--- /dev/null
+++ b/patches/[email protected]
@@ -0,0 +1,69 @@
+diff --git a/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h b/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h
+index 86035915aa330d2011e7c3027ae315c689e40f58..3d43e949550e1bc1311c38d11a7920c237a41018 100644
+--- a/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h
++++ b/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h
+@@ -22,6 +22,7 @@ struct LayoutAnimation {
+ Tag parentTag;
+ std::optional<double> opacity;
+ bool isViewAlreadyMounted = false;
++ bool isExitingWhenSettled = false;
+ int count = 1;
+ LayoutAnimation &operator=(const LayoutAnimation &other) = default;
+
+diff --git a/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.cpp b/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.cpp
+index bc62f8fc31a1d3b08353df514bf4f954c6279ceb..0c16264538a13ae8b7bd4fd11e1227d8580c5c65 100644
+--- a/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.cpp
++++ b/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.cpp
+@@ -290,6 +290,7 @@ std::optional<SurfaceId> LayoutAnimationsProxy_Experimental::endLayoutAnimation(
+ if (--layoutAnimation.count > 0) {
+ return {};
+ }
++ layoutAnimation.isExitingWhenSettled = shouldRemove;
+ maybeSettledAnimationTags_.insert(tag);
+ auto surfaceId = layoutAnimation.finalView.surfaceId;
+
+@@ -407,7 +408,8 @@ void LayoutAnimationsProxy_Experimental::addOngoingAnimations(SurfaceId surfaceI
+
+ const auto layoutAnimationIt = layoutAnimations_.find(tag);
+
+- if (layoutAnimationIt == layoutAnimations_.end() || layoutAnimationIt->second.isSettled()) {
++ if (layoutAnimationIt == layoutAnimations_.end() ||
++ (layoutAnimationIt->second.isSettled() && layoutAnimationIt->second.isExitingWhenSettled)) {
+ continue;
+ }
+
+@@ -554,6 +556,8 @@ void LayoutAnimationsProxy_Experimental::maybeCancelAnimation(const int tag) con
+ }
+ if (layoutAnimationIt->second.isSettled()) {
+ // Already settled - cleanupAnimations will erase it together with its updateMap entry.
++ // Do not flush a pending Update after the caller queues this view for removal.
++ layoutAnimationIt->second.isExitingWhenSettled = true;
+ return;
+ }
+ layoutAnimations_.erase(layoutAnimationIt);
+diff --git a/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.cpp b/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.cpp
+index 9402e3e5ba4859ed344901b8b5884b9f708dd82b..2b1e4294ef798b7b6aabd04cc6663aae8297d034 100644
+--- a/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.cpp
++++ b/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.cpp
+@@ -119,6 +119,7 @@ std::optional<SurfaceId> LayoutAnimationsProxy_Legacy::endLayoutAnimation(int ta
+ if (--layoutAnimation.count > 0) {
+ return {};
+ }
++ layoutAnimation.isExitingWhenSettled = shouldRemove;
+ maybeSettledAnimationTags_.insert(tag);
+ auto surfaceId = layoutAnimation.finalView.surfaceId;
+
+@@ -414,12 +415,7 @@ void LayoutAnimationsProxy_Legacy::addOngoingAnimations(SurfaceId surfaceId, Sha
+ auto layoutAnimationIt = layoutAnimations_.find(tag);
+
+ if (layoutAnimationIt == layoutAnimations_.end() ||
+- // A settled animation is normally cleaned up without applying further
+- // updates. The exception is a flaky entering animation whose opacity was
+- // never restored (the view wasn't mounted in time) - we still need to
+- // apply that pending opacity, otherwise the view stays invisible. Only
+- // entering animations carry an opacity value.
+- (layoutAnimationIt->second.isSettled() && !layoutAnimationIt->second.opacity.has_value())) {
++ (layoutAnimationIt->second.isSettled() && layoutAnimationIt->second.isExitingWhenSettled)) {
+ continue;
+ }
+
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index bebd36cec2e..2cba4e1a877 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -103,6 +103,7 @@ patchedDependencies:
[email protected]: 96573c000f7fe56b5abfa13e2e5f0d065907e674cb8e2300155226d7c9874398
[email protected]: 6e4339347bc5bb3c9ea67d85ff5c814058b211c5750f247aba59d07869a2e787
[email protected]: 825622aae63a8fb5b904f3c77908a0e216261d727ea171709f2c0b6088422675
+ [email protected]: a23baea5d82cbf1254720110aef6671e39d57a425f8be446756f91ab806eb72c
[email protected]: 8156dd0f3407822404793cfdaa95639a36b62102f4507c981b8be83600bb382d
[email protected]: 17d92be2eec71bb6396b402e8d034968e54b28746876d7977cb3139655f42b90
@@ -429,7 +430,7 @@ importers:
react-native-keyboard-controller:
specifier: 1.21.13
react-native-nitro-markdown:
specifier: ^0.5.0
@@ -438,7 +439,7 @@ importers:
version: 0.35.9(patch_hash=825622aae63a8fb5b904f3c77908a0e216261d727ea171709f2c0b6088422675)([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
react-native-reanimated:
specifier: 4.5.1
react-native-safe-area-context:
specifier: ~5.7.0
@@ -20932,12 +20933,12 @@ snapshots:
react: 19.2.3
- dependencies:
+ : dependencies:
react: 19.2.3
dependencies:
@@ -20952,7 +20953,7 @@ snapshots:
react: 19.2.3
dependencies:
react: 19.2.3
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index ae279419d42..8a4bf972f82 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -179,6 +179,8 @@ patchedDependencies:
+ # Preserve the final layout frame. Backport of [#10171](https://github.com/software-mansion/react-native-reanimated/pull/10171).