@@ -15,14 +15,16 @@ import { Transition } from '../internal/components/transition';
15
15
import { getVisualContextClassname } from '../internal/components/visual-context' ;
16
16
import customCssProps from '../internal/generated/custom-css-properties' ;
17
17
import { useEffectOnUpdate } from '../internal/hooks/use-effect-on-update' ;
18
+ import { useMergeRefs } from '../internal/hooks/use-merge-refs' ;
18
19
import { useUniqueId } from '../internal/hooks/use-unique-id' ;
20
+ import { useVisualRefresh } from '../internal/hooks/use-visual-mode' ;
19
21
import { scrollElementIntoView } from '../internal/utils/scrollable-containers' ;
20
22
import { throttle } from '../internal/utils/throttle' ;
21
23
import { GeneratedAnalyticsMetadataFlashbarExpand } from './analytics-metadata/interfaces' ;
22
24
import { getComponentsAnalyticsMetadata , getItemAnalyticsMetadata } from './analytics-metadata/utils' ;
23
25
import { useFlashbar } from './common' ;
24
26
import { Flash , focusFlashById } from './flash' ;
25
- import { FlashbarProps } from './interfaces' ;
27
+ import { FlashbarProps , InternalFlashbarProps } from './interfaces' ;
26
28
import { counterTypes , getFlashTypeCount , getItemColor , getVisibleCollapsedItems , StackableItem } from './utils' ;
27
29
28
30
import styles from './styles.css.js' ;
@@ -33,10 +35,11 @@ const maxNonCollapsibleItems = 1;
33
35
34
36
const resizeListenerThrottleDelay = 100 ;
35
37
36
- export default function CollapsibleFlashbar ( { items, ...restProps } : FlashbarProps ) {
38
+ export default function CollapsibleFlashbar ( { __internalRootRef , items, ...restProps } : InternalFlashbarProps ) {
37
39
const [ enteringItems , setEnteringItems ] = useState < ReadonlyArray < FlashbarProps . MessageDefinition > > ( [ ] ) ;
38
40
const [ exitingItems , setExitingItems ] = useState < ReadonlyArray < FlashbarProps . MessageDefinition > > ( [ ] ) ;
39
41
const [ isFlashbarStackExpanded , setIsFlashbarStackExpanded ] = useState ( false ) ;
42
+ const isVisualRefresh = useVisualRefresh ( ) ;
40
43
41
44
const getElementsToAnimate = useCallback ( ( ) => {
42
45
const flashElements = isFlashbarStackExpanded ? expandedItemRefs . current : collapsedItemRefs . current ;
@@ -48,7 +51,7 @@ export default function CollapsibleFlashbar({ items, ...restProps }: FlashbarPro
48
51
setInitialAnimationState ( rects ) ;
49
52
} , [ getElementsToAnimate ] ) ;
50
53
51
- const { baseProps, breakpoint, isReducedMotion, isVisualRefresh , mergedRef, ref } = useFlashbar ( {
54
+ const { baseProps, breakpoint, isReducedMotion, mergedRef, ref } = useFlashbar ( {
52
55
items,
53
56
...restProps ,
54
57
onItemsAdded : newItems => {
@@ -308,7 +311,7 @@ export default function CollapsibleFlashbar({ items, ...restProps }: FlashbarPro
308
311
isFlashbarStackExpanded && styles . expanded ,
309
312
isVisualRefresh && styles [ 'visual-refresh' ]
310
313
) }
311
- ref = { mergedRef }
314
+ ref = { useMergeRefs ( mergedRef , __internalRootRef ) }
312
315
{ ...getAnalyticsMetadataAttribute ( getComponentsAnalyticsMetadata ( items . length , true , isFlashbarStackExpanded ) ) }
313
316
>
314
317
{ isFlashbarStackExpanded && renderList ( ) }
0 commit comments