Skip to content

Commit c18fd75

Browse files
committed
add clearPromiseQueue to Plotly.react
... on-par with Plotly.restyle, Plotly.relayout and Plotly.update
1 parent ffb67f9 commit c18fd75

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/plot_api/plot_api.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2657,6 +2657,7 @@ function react(gd, data, layout, config) {
26572657
function addFrames() { return exports.addFrames(gd, frames); }
26582658

26592659
gd = Lib.getGraphDiv(gd);
2660+
helpers.clearPromiseQueue(gd);
26602661

26612662
var oldFullData = gd._fullData;
26622663
var oldFullLayout = gd._fullLayout;

test/jasmine/tests/mapbox_test.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,40 @@ describe('@noCI, mapbox plots', function() {
942942
.then(done);
943943
}, LONG_TIMEOUT_INTERVAL);
944944

945+
it('@gl should not wedge graph after reacting to invalid layer', function(done) {
946+
Plotly.react(gd, [{type: 'scattermapbox'}], {
947+
mapbox: {
948+
layers: [{ source: 'invalid' }]
949+
}
950+
})
951+
.then(function() {
952+
fail('The above Plotly.react promise should be rejected');
953+
})
954+
.catch(function() {
955+
expect(gd._promises.length).toBe(1, 'has 1 rejected promise in queue');
956+
})
957+
.then(function() {
958+
return Plotly.react(gd, [{type: 'scattermapbox'}], {
959+
mapbox: {
960+
layers: [{
961+
sourcetype: 'vector',
962+
sourcelayer: 'contour',
963+
source: 'mapbox://mapbox.mapbox-terrain-v2'
964+
}]
965+
}
966+
});
967+
})
968+
.then(function() {
969+
expect(gd._promises.length).toBe(0, 'rejected promise has been cleared');
970+
971+
var mapInfo = getMapInfo(gd);
972+
expect(mapInfo.layoutLayers.length).toBe(1, 'one layer');
973+
expect(mapInfo.layoutSources.length).toBe(1, 'one layer source');
974+
})
975+
.catch(failTest)
976+
.then(done);
977+
}, LONG_TIMEOUT_INTERVAL);
978+
945979
it('@gl should be able to update the access token', function(done) {
946980
Plotly.relayout(gd, 'mapbox.accesstoken', 'wont-work').catch(function(err) {
947981
expect(gd._fullLayout.mapbox.accesstoken).toEqual('wont-work');

0 commit comments

Comments
 (0)