@@ -1544,6 +1544,47 @@ describe('Plotly.react and uirevision attributes', function() {
15441544 _run ( fig , editSelection , checkNoSelection , checkSelection ) . then ( done , done . fail ) ;
15451545 } ) ;
15461546
1547+ it ( 'preserves layout selections using selectionrevision without logging unrecognized GUI edits' , function ( done ) {
1548+ // Regression test for https://github.com/plotly/plotly.js/issues/7809
1549+ // Check that a box selection is correctly recognized by selectionrevision
1550+ // following a call to Plotly.react(), rather than notifying with an
1551+ // "unrecognized GUI edit: selections[0]..." error
1552+ function fig ( mainRev , selectionRev ) {
1553+ return {
1554+ data : [ { y : [ 1 , 3 , 1 ] } , { y : [ 2 , 1 , 3 ] } ] ,
1555+ layout : {
1556+ uirevision : mainRev ,
1557+ selectionrevision : selectionRev ,
1558+ dragmode : 'select' ,
1559+ width : 400 ,
1560+ height : 400 ,
1561+ margin : { l : 100 , t : 100 , r : 100 , b : 100 }
1562+ }
1563+ } ;
1564+ }
1565+
1566+ function editSelection ( ) {
1567+ return drag ( { node : document . querySelector ( '.nsewdrag' ) , dpos : [ 148 , 100 ] , pos0 : [ 150 , 102 ] } ) ;
1568+ }
1569+
1570+ function checkNoSelection ( ) {
1571+ expect ( ( gd . layout . selections || [ ] ) . length ) . toBe ( 0 , 'layout.selections cleared' ) ;
1572+ }
1573+ function checkSelection ( ) {
1574+ expect ( ( gd . layout . selections || [ ] ) . length ) . toBe ( 1 , 'layout.selections preserved' ) ;
1575+ }
1576+
1577+ var warnings = [ ] ;
1578+ spyOn ( Lib , 'warn' ) . and . callFake ( function ( msg ) { warnings . push ( msg ) ; } ) ;
1579+
1580+ _run ( fig , editSelection , checkNoSelection , checkSelection ) . then ( function ( ) {
1581+ var guiEditWarnings = warnings . filter ( function ( msg ) {
1582+ return String ( msg ) . indexOf ( 'unrecognized GUI edit' ) !== - 1 ;
1583+ } ) ;
1584+ expect ( guiEditWarnings ) . toEqual ( [ ] , 'no unrecognized GUI edit warnings' ) ;
1585+ } ) . then ( done , done . fail ) ;
1586+ } ) ;
1587+
15471588 it ( 'preserves polar view changes using polar.uirevision' , function ( done ) {
15481589 // polar you can control either at the subplot or the axis level
15491590 function fig ( mainRev , polarRev ) {
0 commit comments