@@ -513,6 +513,72 @@ describe('responsive behaviour in container', () => {
513513 } ) ;
514514} ) ;
515515
516+ describe ( 'parent resize' , ( ) => {
517+ let container , text , menu , buttons ;
518+
519+ beforeEach ( ( ) => {
520+ container = fixtureSync ( '<div style="display: flex; max-width: 300px"></div>' ) ;
521+ text = document . createElement ( 'div' ) ;
522+ text . textContent = 'Sibling' ;
523+ menu = document . createElement ( 'vaadin-menu-bar' ) ;
524+ menu . items = [ { text : 'Item 1' } , { text : 'Item 2' } , { text : 'Item 3' } , { text : 'Item 4' } ] ;
525+ menu . style . minWidth = '100px' ;
526+ } ) ;
527+
528+ describe ( 'container' , ( ) => {
529+ beforeEach ( async ( ) => {
530+ container . append ( text , menu ) ;
531+ await onceResized ( menu ) ;
532+ buttons = menu . _buttons ;
533+ } ) ;
534+
535+ it ( 'should show buttons when container width increases and menu-bar width stays the same' , async ( ) => {
536+ assertHidden ( buttons [ 2 ] ) ;
537+ assertHidden ( buttons [ 3 ] ) ;
538+
539+ container . style . maxWidth = '400px' ;
540+ await onceResized ( menu ) ;
541+
542+ assertVisible ( buttons [ 2 ] ) ;
543+ assertVisible ( buttons [ 3 ] ) ;
544+ } ) ;
545+
546+ it ( 'should show buttons after attaching another container and increasing its width' , async ( ) => {
547+ const other = document . createElement ( 'div' ) ;
548+ other . style . display = 'flex' ;
549+ other . style . maxWidth = '300px' ;
550+ container . parentNode . appendChild ( other ) ;
551+
552+ other . append ( text , menu ) ;
553+ other . style . maxWidth = '400px' ;
554+ await onceResized ( menu ) ;
555+
556+ assertVisible ( buttons [ 2 ] ) ;
557+ assertVisible ( buttons [ 3 ] ) ;
558+ } ) ;
559+ } ) ;
560+
561+ describe ( 'shadow host' , ( ) => {
562+ beforeEach ( async ( ) => {
563+ container . attachShadow ( { mode : 'open' } ) ;
564+ container . shadowRoot . append ( text , menu ) ;
565+ await onceResized ( menu ) ;
566+ buttons = menu . _buttons ;
567+ } ) ;
568+
569+ it ( 'should show buttons when shadow host width increases and menu-bar width stays the same' , async ( ) => {
570+ assertHidden ( buttons [ 2 ] ) ;
571+ assertHidden ( buttons [ 3 ] ) ;
572+
573+ container . style . maxWidth = '400px' ;
574+ await onceResized ( menu ) ;
575+
576+ assertVisible ( buttons [ 2 ] ) ;
577+ assertVisible ( buttons [ 3 ] ) ;
578+ } ) ;
579+ } ) ;
580+ } ) ;
581+
516582describe ( 'item components' , ( ) => {
517583 let menu , buttons , overflow ;
518584
0 commit comments