@@ -13,7 +13,8 @@ import {
13
13
ToolbarSeparator ,
14
14
ToolbarSpacer ,
15
15
ToolbarStyle ,
16
- OverflowToolbarToggleButton
16
+ OverflowToolbarToggleButton ,
17
+ ToolbarPropTypes
17
18
} from '../..' ;
18
19
import { ButtonDesign , ToolbarDesign } from '../../enums' ;
19
20
import { cssVarToRgb , cypressPassThroughTestsFactory , mountWithCustomTagName } from '@/cypress/support/utils' ;
@@ -490,6 +491,49 @@ describe('Toolbar', () => {
490
491
cy . findByTestId ( 'tb' ) . should ( 'have.css' , 'boxShadow' , 'rgb(0, 112, 242) 0px 0px 0px 2px inset' ) ;
491
492
} ) ;
492
493
494
+ it ( 'recalc on children change' , ( ) => {
495
+ const TestComp = ( props : ToolbarPropTypes ) => {
496
+ const [ actions , setActions ] = useState ( [ ] ) ;
497
+ return (
498
+ < >
499
+ < button
500
+ onClick = { ( ) => {
501
+ setActions ( [
502
+ < Button key = "0" > Button</ Button > ,
503
+ < Button key = "1" > Button</ Button > ,
504
+ < Button key = "2" > Button</ Button > ,
505
+ < Button key = "3" > Button</ Button > ,
506
+ < Button key = "4" > Button</ Button > ,
507
+ < Button key = "5" > Button</ Button > ,
508
+ < Button key = "6" > Button</ Button > ,
509
+ < Button key = "7" > Button</ Button >
510
+ ] ) ;
511
+ } }
512
+ >
513
+ add
514
+ </ button >
515
+ < button
516
+ onClick = { ( ) => {
517
+ setActions ( [ ] ) ;
518
+ } }
519
+ >
520
+ remove
521
+ </ button >
522
+ < Toolbar { ...props } > { actions } </ Toolbar >
523
+ </ >
524
+ ) ;
525
+ } ;
526
+ const overflowChange = cy . spy ( ) . as ( 'overflowChange' ) ;
527
+ cy . mount ( < TestComp onOverflowChange = { overflowChange } style = { { width : '200px' } } /> ) ;
528
+
529
+ cy . get ( '[ui5-toggle-button]' ) . should ( 'not.exist' ) ;
530
+ cy . findByText ( 'add' ) . click ( ) ;
531
+ cy . get ( '[ui5-toggle-button]' ) . should ( 'be.visible' ) ;
532
+ cy . findByText ( 'remove' ) . click ( ) ;
533
+ cy . get ( '[ui5-toggle-button]' ) . should ( 'not.exist' ) ;
534
+ cy . get ( '@overflowChange' ) . should ( 'have.been.calledOnce' ) ;
535
+ } ) ;
536
+
493
537
mountWithCustomTagName ( Toolbar ) ;
494
538
cypressPassThroughTestsFactory ( Toolbar ) ;
495
539
} ) ;
0 commit comments