@@ -9,11 +9,15 @@ import { observeResize } from "~/lib/observeResize";
99
1010// Match the duration-220 exit transition before removing a dismissed notice.
1111const DISMISS_TRANSITION_MS = 220 ;
12+ // How long a revealed notice stays open before tucking behind the front banner.
13+ const REVEAL_MS = 5_000 ;
1214
1315export interface ComposerBannerStackItem {
1416 readonly id : string ;
1517 readonly variant : ComposerBannerVariant ;
1618 readonly priority ?: "urgent" | "activity" | "notice" ;
19+ /** The user asked for this notice, so it opens the stack when it lands behind another banner. */
20+ readonly reveal ?: boolean ;
1721 readonly icon : ReactNode ;
1822 readonly title : ReactNode ;
1923 readonly description ?: ReactNode ;
@@ -73,6 +77,27 @@ export function ComposerBannerStack({ className, items, attachedAbove }: Compose
7377 setStackExpanded ( false ) ;
7478 }
7579
80+ const orderedItems = items . toSorted ( ( a , b ) => bannerPriority ( a ) - bannerPriority ( b ) ) ;
81+ const stackedItems = orderedItems . slice ( 1 ) ;
82+ const revealItemId =
83+ stackedItems . find ( ( item ) => "reveal" in item && item . reveal === true ) ?. id ?? null ;
84+ const [ revealedItemId , setRevealedItemId ] = useState < string | null > ( null ) ;
85+ if ( revealItemId !== null && revealItemId !== revealedItemId ) {
86+ setRevealedItemId ( revealItemId ) ;
87+ setStackExpanded ( true ) ;
88+ }
89+
90+ // Tuck the revealed notice away unless the user is reading it; leaving it collapses as usual.
91+ useEffect ( ( ) => {
92+ if ( revealedItemId === null ) return ;
93+ const timeout = setTimeout ( ( ) => {
94+ const notices = noticesRef . current ;
95+ if ( notices ?. matches ( ":hover" ) || notices ?. contains ( document . activeElement ) ) return ;
96+ setStackExpanded ( false ) ;
97+ } , REVEAL_MS ) ;
98+ return ( ) => clearTimeout ( timeout ) ;
99+ } , [ revealedItemId ] ) ;
100+
76101 useLayoutEffect ( ( ) => {
77102 if ( stackExpanded && pendingFocusRef . current === "notice" ) {
78103 pendingFocusRef . current = null ;
@@ -86,7 +111,6 @@ export function ComposerBannerStack({ className, items, attachedAbove }: Compose
86111 }
87112 } , [ stackExpanded ] ) ;
88113
89- const orderedItems = items . toSorted ( ( a , b ) => bannerPriority ( a ) - bannerPriority ( b ) ) ;
90114 const frontItem = orderedItems [ 0 ] ;
91115 if ( ! frontItem ) {
92116 return (
@@ -97,7 +121,6 @@ export function ComposerBannerStack({ className, items, attachedAbove }: Compose
97121 </ >
98122 ) ;
99123 }
100- const stackedItems = orderedItems . slice ( 1 ) ;
101124 const hasStack = stackedItems . length > 0 ;
102125 const showCollapsedStackCap = hasStack && exitingItemId !== frontItem . id ;
103126 const firstStackedItem = stackedItems [ 0 ] ;
0 commit comments