Skip to content

Commit bf9508c

Browse files
authored
Merge pull request #7836 from plotly/7809-fix
Fix "Unrecognized GUI edit" warning
2 parents 8965c3d + 329517e commit bf9508c

3 files changed

Lines changed: 43 additions & 0 deletions

File tree

draftlogs/7836_fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fix "unrecognized GUI edit: selections[0]..." warnings emitted after making a box or lasso selection and then calling `Plotly.react()` [[#7836](https://github.com/plotly/plotly.js/issues/7836)]

src/plot_api/plot_api.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2338,6 +2338,7 @@ var layoutUIControlPatterns = [
23382338

23392339
{ pattern: /^legend\.(x|y)$/, attr: 'editrevision' },
23402340
{ pattern: /^(shapes|annotations)/, attr: 'editrevision' },
2341+
{ pattern: /^selections/, attr: 'selectionrevision' },
23412342
{ pattern: /^title\.text$/, attr: 'editrevision' }
23422343
];
23432344

test/jasmine/tests/plot_api_react_test.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)