@@ -35,6 +35,8 @@ import {
3535 getFlashTypeCount ,
3636 getItemColor ,
3737 getVisibleCollapsedItems ,
38+ isRefObject ,
39+ isStackableItem ,
3840 StackableItem ,
3941} from './utils' ;
4042
@@ -214,11 +216,11 @@ export default function CollapsibleFlashbar({ items, style, ...restProps }: Inte
214216 // we need to use different, more custom and more controlled animations.
215217 const hasEntered = ( item : StackableItem | FlashbarProps . MessageDefinition ) =>
216218 enteringItems . some ( _item => _item . id && _item . id === item . id ) ;
217- const hasLeft = ( item : StackableItem | FlashbarProps . MessageDefinition ) => ! ( 'expandedIndex' in item ) ;
219+ const hasLeft = ( item : StackableItem | FlashbarProps . MessageDefinition ) => ! isStackableItem ( item ) ;
218220 const hasEnteredOrLeft = ( item : StackableItem | FlashbarProps . MessageDefinition ) => hasEntered ( item ) || hasLeft ( item ) ;
219221
220222 const showInnerContent = ( item : StackableItem | FlashbarProps . MessageDefinition ) =>
221- isFlashbarStackExpanded || hasLeft ( item ) || ( 'expandedIndex' in item && item . expandedIndex === 0 ) ;
223+ isFlashbarStackExpanded || hasLeft ( item ) || ( isStackableItem ( item ) && item . expandedIndex === 0 ) ;
222224
223225 const shouldUseStandardAnimation = ( item : StackableItem , index : number ) => index === 0 && hasEnteredOrLeft ( item ) ;
224226
@@ -301,11 +303,7 @@ export default function CollapsibleFlashbar({ items, style, ...restProps }: Inte
301303 if ( shouldUseStandardAnimation ( item , index ) && transitionRootElement ) {
302304 if ( typeof transitionRootElement === 'function' ) {
303305 transitionRootElement ( el ) ;
304- } else if (
305- transitionRootElement &&
306- typeof transitionRootElement === 'object' &&
307- 'current' in transitionRootElement
308- ) {
306+ } else if ( isRefObject ( transitionRootElement ) ) {
309307 ( transitionRootElement as React . MutableRefObject < HTMLDivElement | null > ) . current = el ;
310308 }
311309 }
0 commit comments