[animations-reanimated] An exit never completes when the element has a keyword width such as max-content
Current Behavior
Under @tamagui/animations-reanimated on web, an element leaving an AnimatePresence with width: 'max-content' fades out but is never removed. It stays in the DOM at opacity 0 for as long as the page is open. The same element with a numeric width, or with no width, unmounts once the exit finishes.
We hit it on Popover.Content: a dismissed popover kept its panel in the document.
Expected Behavior
A style value the driver cannot animate does not hold the exit open. The exit completes once the animatable keys settle, as it already does for 'auto' and calc(...).
Tamagui Version
2.7.7 (@tamagui/animations-reanimated 2.7.7, react-native-reanimated 4.2.1).
Platform (Web, iOS, Android)
Web (react-native-web 0.21.2).
Reproduction
const Keyword = styled(Popover.Content, { width: 'max-content' })
const Numeric = styled(Popover.Content, { width: 240 })
const Probe = ({ Content }) => {
const [open, setOpen] = useState(false)
return (
<Popover open={open} onOpenChange={setOpen}>
<Popover.Trigger asChild>
<button>trigger</button>
</Popover.Trigger>
<Content
testID="content"
transition="quick"
enterStyle={{ y: -10, opacity: 0 }}
exitStyle={{ y: -10, opacity: 0 }}
>
<View width={200} height={100} backgroundColor="red" />
</Content>
</Popover>
)
}Open, close, wait 1.5s, and check whether [data-testid="content"] is still in the document:
| Content | After close |
|---|---|
Popover.Content |
removed |
width: 240 |
removed |
backgroundColor / borderRadius tokens |
removed |
width: 'max-content' |
still mounted, opacity 0 |
With animateOnly={['opacity', 'transform']} on the max-content case, the content is removed.
Cause
useAnimations registers every gated animated key as pending on exit and calls sendExitComplete only once all of them report finished. canAnimateProperty excludes 'auto' and calc(...) strings, so those never become gated keys:
const canAnimateProperty = (key, value, animateOnly) => {
// …
if (value === "auto") return false;
if (typeof value === "string" && value.startsWith("calc")) return false;
// …
};'max-content' passes that check, and so would 'min-content' and 'fit-content'. The width key is registered as pending, never reports finished, and the exit stays pending. We confirmed this with max-content only.
Workaround
Limit the animation to the keys that actually change:
<Popover.Content animateOnly={['opacity', 'transform']} … />Possible fix
Treat any non-numeric, non-colour string that is not a transform as non-animatable in canAnimateProperty, or at least add the CSS intrinsic sizing keywords next to 'auto'.
System Info
- macOS 26.5, Apple M1
- Node 26.4.0, bun 1.2.23
tamagui/@tamagui/core/@tamagui/animations-reanimated2.7.7react-native-reanimated4.2.1,react19.2.0,react-native-web0.21.2- Vite (Storybook 10)
Source: tamagui/tamagui