-
Notifications
You must be signed in to change notification settings - Fork 192
fix(useCSSTransition): fix fast state changing #8890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(useCSSTransition): fix fast state changing #8890
Conversation
size-limit report 📦
|
e2e tests |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #8890 +/- ##
=======================================
Coverage 96.02% 96.03%
=======================================
Files 428 428
Lines 12449 12472 +23
Branches 4105 4113 +8
=======================================
+ Hits 11954 11977 +23
Misses 495 495
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
👀 Docs deployed
📦 Package ✅yarn add @vkontakte/vkui@https://vkui-screenshot.hb.bizmrg.com/pull/8890/99fc17f872fa357c520d3caa0b4a0d337ad5be86/pkg/@vkontakte/vkui/_pkg.tgz Commit 99fc17f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
а в useCSSKeyframesAnimationController
нужно повторить?
Там логика немного другая. Лучше, если будут кейсы, тогда поправим |
* fix(useCSSTransition): fix fast state changing * fix(useCSSTransition): fix import * fix: fix code review * fix: add condition when duration <= 0 * fix: delete useStateWithPrev * fix: add timer delay * test: fix test * test: add test * fix: use useIsomorphicLayoutEffect instead of useEffect * fix: use useIsomorphicLayoutEffect instead of useEffect
Описание
Исправляет баг, при котором компонент мог зависать в состоянии
exiting
при очень быстром открытии/закрытии (например: открыть → сразу закрыть). Корневая причина — полагание только на событиеtransitionend
, которое в ряде реальных сценариев не гарантировано:transition
может не стартовать (CSS-значения до/после совпадают), поэтомуtransitionend
не придёт;transition-delay
или задержки, которые разбегаются с ожиданиями в JS;display: none
до конца анимации;transitionend
генерируется по каждому свойству и не всегда даёт простую семантику "анимация завершена" для корневого элемента.Из-за этого хук иногда оставался в
exiting
— ниtransitionend
, ни логика в JS не переводили состояние дальше.Изменения
getComputedStyle
—transition-duration
+transition-delay
) и ставит fallback-таймер при входе в активные состояния (appearing
,entering
,exiting
).transitionend
приходит — таймер очищается и завершение происходит по событию. Если событие не пришло — таймер форсирует завершение, предотвращая "зависание".Release notes
Исправления