@@ -55,6 +55,12 @@ function stubPanelSize(panel: HTMLElement, width: number, height: number) {
5555 } ) as DOMRect ;
5656}
5757
58+ const DEFAULT_INNER_WIDTH = window . innerWidth ;
59+
60+ function setViewportWidth ( width : number ) {
61+ Object . defineProperty ( window , 'innerWidth' , { value : width , configurable : true , writable : true } ) ;
62+ }
63+
5864async function waitFor ( cond : ( ) => boolean , timeout = 800 ) : Promise < void > {
5965 const start = Date . now ( ) ;
6066 while ( ! cond ( ) ) {
@@ -67,6 +73,7 @@ describe('Flyout', () => {
6773 beforeEach ( ( ) => {
6874 document . body . innerHTML = '' ;
6975 document . body . style . overflow = '' ;
76+ setViewportWidth ( DEFAULT_INNER_WIDTH ) ;
7077 } ) ;
7178
7279 // --- Open / Close ---
@@ -352,4 +359,39 @@ describe('Flyout', () => {
352359
353360 expect ( flyout . open ) . toBe ( true ) ;
354361 } ) ;
362+
363+ // --- Inline (sidebar) mode ---
364+
365+ it ( 'does not auto-open above the inline breakpoint (sidebar is shown via CSS)' , ( ) => {
366+ setViewportWidth ( 1280 ) ;
367+ const flyout = createFlyout ( 'test-flyout' , { open : true , inline : 1024 } ) ;
368+ expect ( flyout . open ) . toBe ( false ) ;
369+ expect ( flyout . hasAttribute ( 'data-hui-flyout-open' ) ) . toBe ( false ) ;
370+ } ) ;
371+
372+ it ( 'ignores open() while above the inline breakpoint' , ( ) => {
373+ setViewportWidth ( 1280 ) ;
374+ const flyout = createFlyout ( 'test-flyout' , { inline : 1024 } ) ;
375+ openFlyout ( 'test-flyout' ) ;
376+ expect ( flyout . open ) . toBe ( false ) ;
377+ } ) ;
378+
379+ it ( 'behaves as a normal drawer below the inline breakpoint' , ( ) => {
380+ setViewportWidth ( 800 ) ;
381+ const flyout = createFlyout ( 'test-flyout' , { inline : 1024 } ) ;
382+ openFlyout ( 'test-flyout' ) ;
383+ expect ( flyout . open ) . toBe ( true ) ;
384+ closeFlyout ( 'test-flyout' ) ;
385+ expect ( flyout . open ) . toBe ( false ) ;
386+ } ) ;
387+
388+ it ( 'never sets a presentation mode attribute (inline styling is CSS-driven)' , ( ) => {
389+ setViewportWidth ( 1280 ) ;
390+ const inline = createFlyout ( 'test-flyout' , { inline : 1024 } ) ;
391+ expect ( inline . hasAttribute ( 'data-hui-flyout-mode' ) ) . toBe ( false ) ;
392+
393+ setViewportWidth ( 800 ) ;
394+ const drawer = createFlyout ( 'drawer-flyout' , { inline : 1024 } ) ;
395+ expect ( drawer . hasAttribute ( 'data-hui-flyout-mode' ) ) . toBe ( false ) ;
396+ } ) ;
355397} ) ;
0 commit comments