[BUG] animate change made while inside a hidden <Activity> is ignored on reveal
I maintainer di solito rispondono entro 1 giorno
Una pull request collegata è già stata integrata.
- #3950 di @mattgperry — integrata
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- react, typescript
- Ambito
- frontend
Direzione di ricerca
Start in useVisualElement, where the insertion effect calls visualElement.update only after isMounted.current is set in a layout effect; a hidden <Activity> never runs layout effects, so updates are skipped. The repro test in the linked repository (the first test, which fails, with the second as a control) is the check for the fix. Done means the test passes and the existing suite still passes, with the animation reaching the latest animate value on reveal.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
1. Read the FAQs
Done.
2. Describe the bug
A motion.div that first mounts inside <Activity mode="hidden"> ignores any animate change made before the Activity is shown. On reveal it animates to the animate value from its first render.
In useVisualElement, the insertion effect only calls visualElement.update(props, presenceContext) once isMounted.current is true, and isMounted is set in a layout effect. A hidden Activity runs no layout effects, so every re-render before the reveal skips update. When the Activity is shown, animateChanges() runs against the props from the first render.
This is close to #3832 but a different case: there the element had mounted visibly before being hidden. Here it has never been visible.
3. Reproduction
https://stackblitz.com/github/mdluo/motion-activity-repro (run npm install && npm test; source: https://github.com/mdluo/motion-activity-repro). The first test fails, the second is a control that passes.
import { render, waitFor } from "@testing-library/react"
import { motion } from "framer-motion"
import { Activity } from "react"
function Panel({ shown, active }: { shown: boolean; active: boolean }) {
return (
<Activity mode={shown ? "visible" : "hidden"}>
<motion.div
data-testid="box"
initial={{ opacity: 0 }}
animate={{ opacity: active ? 1 : 0 }}
/>
</Activity>
)
}
test("animate prop changed while hidden is used on reveal", async () => {
const { rerender, getByTestId } = render(<Panel shown={false} active={false} />)
rerender(<Panel shown={false} active />)
rerender(<Panel shown active />)
await waitFor(() => expect(getByTestId("box").style.opacity).toBe("1"))
})
4. Steps to reproduce
- Mount the element inside a hidden
<Activity>withanimate={{ opacity: 0 }}. - While still hidden, re-render with
animate={{ opacity: 1 }}. - Show the Activity.
- Opacity stays at 0.
5. Expected behavior
On reveal the element animates to opacity: 1, the animate value of the latest render.
6. Environment details
framer-motion 13.4.4 and 14.3.0, React 19.2.0 and 19.3.0. Seen in Chrome; the test fails in jsdom and happy-dom.
Possible fix
This passes the test above and our app's suites. We are running it as a local patch:
// useVisualElement, in the layout effect that sets isMounted
if (!isMounted.current) visualElement.update(props, presenceContext)
isMounted.current = true
The repro and the patch were written with an AI assistant; we ran the test against both the stock and the patched package.
- Lingua principale
- TypeScript
- Stelle
- 34.4k
- Fork
- 1.4k
- Merge medio
- 23h 3m
- PR unite (30g)
- 108
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di motiondivision/motion
-
[FEATURE] AnimateSuspense for transitions between suspense fallbacks and streamed contentForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertafeature
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
motiondivision/motion#3173 · 9 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
motiondivision/motion#2662 · 2 commenti · 4 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
[FEATURE] Keyboard accessible reorderingForse già presa @mattgperry l’ha presa 1 giorno fa. Apertafeature
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
motiondivision/motion#2658 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
motiondivision/motion#2546 · 4 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
[FEATURE] Manually update animations without `requestAnimationFrame`Forse già presa Una pull request collegata a questa issue è aperta o già unita. Apertafeature
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
motiondivision/motion#2496 · 2 commenti · 3 reazioni ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di motiondivision/motion
Issue simili
-
[BUG] rag: sentence content can cross the reported sentence boundariesForse già presa @LJK-ikun l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
bug needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
README: the Resource URI Schemas example's file://documents/* pattern only matches that literal URIAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
platformatic/mcp#361 ·
I maintainer di solito rispondono entro 1 giorno
-
frontend
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Push: sem service worker ou sem VAPID, o interruptor de Notificações fica ligado sem avisar nadaAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
melgarafael/DeskcommCRM#3164 ·
I maintainer di solito rispondono entro 1 giorno