@@ -469,6 +469,68 @@ def test_tabs_with_children_undefined(self):
469
469
470
470
self .snapshot ('Tabs component with children undefined' )
471
471
472
+ def test_graph_does_not_resize_in_tabs (self ):
473
+ app = dash .Dash (__name__ )
474
+
475
+ app .layout = html .Div ([
476
+ html .H1 ('Dash Tabs component demo' ),
477
+ dcc .Tabs (id = "tabs-example" , value = 'tab-1-example' , children = [
478
+ dcc .Tab (label = 'Tab One' , value = 'tab-1-example' , id = 'tab-1' ),
479
+ dcc .Tab (label = 'Tab Two' , value = 'tab-2-example' , id = 'tab-2' ),
480
+ ]),
481
+ html .Div (id = 'tabs-content-example' )
482
+ ])
483
+
484
+
485
+ @app .callback (Output ('tabs-content-example' , 'children' ),
486
+ [Input ('tabs-example' , 'value' )])
487
+ def render_content (tab ):
488
+ if tab == 'tab-1-example' :
489
+ return html .Div ([
490
+ html .H3 ('Tab content 1' ),
491
+ dcc .Graph (
492
+ id = 'graph-1-tabs' ,
493
+ figure = {
494
+ 'data' : [{
495
+ 'x' : [1 , 2 , 3 ],
496
+ 'y' : [3 , 1 , 2 ],
497
+ 'type' : 'bar'
498
+ }]
499
+ }
500
+ )
501
+ ])
502
+ elif tab == 'tab-2-example' :
503
+ return html .Div ([
504
+ html .H3 ('Tab content 2' ),
505
+ dcc .Graph (
506
+ id = 'graph-2-tabs' ,
507
+ figure = {
508
+ 'data' : [{
509
+ 'x' : [1 , 2 , 3 ],
510
+ 'y' : [5 , 10 , 6 ],
511
+ 'type' : 'bar'
512
+ }]
513
+ }
514
+ )
515
+ ])
516
+ self .startServer (app = app )
517
+
518
+ tab_one = self .wait_for_element_by_css_selector ('#tab-1' )
519
+ tab_two = self .wait_for_element_by_css_selector ('#tab-2' )
520
+
521
+ self .snapshot ("Tabs with Graph - initial (graph should not resize)" )
522
+
523
+ tab_two .click ()
524
+ time .sleep (1 )
525
+
526
+ self .snapshot ("Tabs with Graph - clicked tab 2 (graph should not resize)" )
527
+
528
+ tab_one .click ()
529
+ time .sleep (1 )
530
+
531
+ self .snapshot ("Tabs with Graph - clicked tab 1 (graph should not resize)" )
532
+
533
+
472
534
def test_location_link (self ):
473
535
app = dash .Dash (__name__ )
474
536
0 commit comments