Skip to content

Commit 1b1880f

Browse files
committed
fix(notification): correct TransitionGroup class mapping for leave animation
@v-c/util's shared getTransitionGroupProps puts `-leave-active` in leaveActiveClass, which means notices jump straight to opacity:0 on leave without animating — the CSS target state class is applied together with the starting state in the same frame, so no transition runs. Inline a NotificationList-specific mapping that puts the rc-motion suffixes in the right Vue lifecycle slots: - enterFromClass / leaveFromClass = starting state (-start) - enterActiveClass / leaveActiveClass = transition base (no -start / no -active so they don't fight the from/to) - enterToClass / leaveToClass = target state (-active) Combined with the notice's own `transition: opacity, transform, ...` declaration, the leave animation now runs (opacity 1 → 0) instead of flashing off. Bump to 2.0.0-rc.3.
1 parent 27cc8be commit 1b1880f

2 files changed

Lines changed: 32 additions & 4 deletions

File tree

packages/notification/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@v-c/notification",
33
"type": "module",
4-
"version": "2.0.0-rc.2",
4+
"version": "2.0.0-rc.3",
55
"publishConfig": {
66
"access": "public"
77
},

packages/notification/src/NotificationList/index.tsx

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,37 @@ import type {
77
NotificationStyles as NoticeStyles,
88
} from '../Notification'
99
import { clsx } from '@v-c/util'
10-
import { getTransitionGroupProps } from '@v-c/util/dist/utils/transition'
1110
import { unrefElement } from '@v-c/util/dist/vueuse/unref-element'
1211
import { computed, defineComponent, ref, shallowRef, toRef, TransitionGroup, watch, watchEffect } from 'vue'
12+
13+
/**
14+
* Map Vue's TransitionGroup enter/leave class hooks onto the rc-motion
15+
* style class names that antdv-next 6.4.0 notification styles target
16+
* (-enter-start / -enter-active / -leave-start / -leave-active).
17+
*
18+
* The shared @v-c/util getTransitionGroupProps puts -leave-active in the
19+
* leaveActiveClass, which means the notice jumps straight to opacity:0
20+
* on leave without animating. Wire each phase to the correct rc-motion
21+
* suffix so the opacity/transform transition runs.
22+
*/
23+
function buildMotionGroupProps(name: string, override?: Partial<TransitionGroupProps>): TransitionGroupProps {
24+
return {
25+
name,
26+
appear: true,
27+
// ENTER: from = opacity 0 (-enter-start / -appear-start)
28+
// to = opacity 1 (-enter-active / -appear-active)
29+
enterFromClass: `${name} ${name}-enter ${name}-appear ${name}-enter-start ${name}-appear-start`,
30+
enterActiveClass: `${name} ${name}-enter ${name}-appear`,
31+
enterToClass: `${name} ${name}-enter ${name}-appear ${name}-enter-active ${name}-appear-active`,
32+
// LEAVE: from = opacity 1 (-leave-start)
33+
// to = opacity 0 (-leave-active)
34+
leaveFromClass: `${name} ${name}-leave ${name}-leave-start`,
35+
leaveActiveClass: `${name} ${name}-leave`,
36+
leaveToClass: `${name} ${name}-leave ${name}-leave-active`,
37+
moveClass: `${name} ${name}-move`,
38+
...override,
39+
}
40+
}
1341
import useListPosition from '../hooks/useListPosition'
1442
import useStack from '../hooks/useStack'
1543
import Notification from '../Notification'
@@ -185,8 +213,8 @@ const NotificationList = defineComponent<NotificationListProps>(
185213
const positionResult = position.value
186214

187215
let motionGroupProps: TransitionGroupProps = {}
188-
if (placementMotion.value) {
189-
motionGroupProps = getTransitionGroupProps(placementMotion.value.name!, placementMotion.value)
216+
if (placementMotion.value?.name) {
217+
motionGroupProps = buildMotionGroupProps(placementMotion.value.name, placementMotion.value)
190218
}
191219

192220
const renderItems = () =>

0 commit comments

Comments
 (0)