@@ -2616,7 +2616,17 @@ function react(gd, data, layout, config) {
26162616 }
26172617
26182618 if ( configChanged ) {
2619- plotDone = exports . newPlot ( gd , data , layout , config ) ;
2619+ // Save event listeners as newPlot will remove them
2620+ const eventListeners = gd . _ev . eventNames ( ) . map ( name => [ name , gd . _ev . listeners ( name ) ] ) ;
2621+ plotDone = exports . newPlot ( gd , data , layout , config )
2622+ . then ( ( ) => {
2623+ for ( const [ name , callbacks ] of eventListeners ) {
2624+ callbacks . forEach ( ( cb ) => gd . on ( name , cb ) ) ;
2625+ }
2626+
2627+ // Call react in case transition should have occurred along with config change
2628+ return exports . react ( gd , data , layout , config )
2629+ } ) ;
26202630 } else {
26212631 gd . data = data || [ ] ;
26222632 helpers . cleanData ( gd . data ) ;
@@ -2683,7 +2693,7 @@ function react(gd, data, layout, config) {
26832693 // only used when 'transition' is set by user and
26842694 // when at least one animatable attribute has changed,
26852695 // N.B. config changed aren't animatable
2686- if ( newFullLayout . transition && ! configChanged && ( restyleFlags . anim || relayoutFlags . anim ) ) {
2696+ if ( newFullLayout . transition && ( restyleFlags . anim || relayoutFlags . anim ) ) {
26872697 if ( relayoutFlags . ticks ) seq . push ( subroutines . doTicksRelayout ) ;
26882698
26892699 Plots . doCalcdata ( gd ) ;
@@ -2692,7 +2702,7 @@ function react(gd, data, layout, config) {
26922702 seq . push ( function ( ) {
26932703 return Plots . transitionFromReact ( gd , restyleFlags , relayoutFlags , oldFullLayout ) ;
26942704 } ) ;
2695- } else if ( restyleFlags . fullReplot || relayoutFlags . layoutReplot || configChanged ) {
2705+ } else if ( restyleFlags . fullReplot || relayoutFlags . layoutReplot ) {
26962706 gd . _fullLayout . _skipDefaults = true ;
26972707 seq . push ( exports . _doPlot ) ;
26982708 } else {
@@ -2737,11 +2747,8 @@ function react(gd, data, layout, config) {
27372747 }
27382748 }
27392749
2740- return plotDone . then ( function ( ) {
2741- gd . emit ( 'plotly_react' , {
2742- data : data ,
2743- layout : layout
2744- } ) ;
2750+ return plotDone . then ( ( ) => {
2751+ if ( ! configChanged ) gd . emit ( 'plotly_react' , { config, data, layout } ) ;
27452752
27462753 return gd ;
27472754 } ) ;
0 commit comments