The Wayback Machine - https://web.archive.org/web/20220519204103/https://github.com/plotly/plotly.js/pull/5181
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix modebar not recreated when makePlotFramework called #5181

Merged
merged 3 commits into from Oct 1, 2020
Merged

Fix modebar not recreated when makePlotFramework called #5181

merged 3 commits into from Oct 1, 2020

Conversation

Yook74
Copy link

@Yook74 Yook74 commented Sep 30, 2020

Fixes #4974

If makePlotFramework was called when updating an existing plot, the modebar div would be cleared, but gd._fullLayout._modeBar which tracks the modebar's state would not be changed. If gd._fullLayout._modeBar was not changed, this conditional
would update the modebar instead of creating it. Updating the modebar in this context does not work though, since the modebar div has been cleared.

My extremely simple fix is to clear the modebar's state stored in gd._fullLayout._modeBar when clearing the modebar div in makePlotFramework.

@alexcjohnson
Copy link
Contributor

@alexcjohnson alexcjohnson commented Oct 1, 2020

Thanks @Yook74! this indeed looks like exactly the right fix 🎉

The only thing we need now is a test - ideally this would be something like the modebar styling tests - createGraphDiv before, destroyGraphDiv after, and the test itself would be

Plotly.plot(gd, data, layout).then(function() {
    // test that the initial modebar is present
    var modeBar = gd._fullLayout._modeBar;
    expect(countGroups(modeBar)).toEqual(6); // whatever buttons should be there

    // some modification that would have broken the modebar before your fix:
    // react, restyle, click a button... whatever's easiest
    return Plotly.react(gd, newData, newLayout);
}).then(function() {
    // test that the new modebar is present
    var modeBar = gd._fullLayout._modeBar;
    expect(countGroups(modeBar)).toEqual(12); // different (nonzero) number of buttons
})
.catch(failTest)
.then(done)

@archmoj archmoj removed the request for review from antoinerg Oct 1, 2020
@Yook74
Copy link
Author

@Yook74 Yook74 commented Oct 1, 2020

I wrote tests to catch the particular problem I was having (#4974).

@archmoj
Copy link
Contributor

@archmoj archmoj commented Oct 1, 2020

I wrote tests to catch the particular problem I was having (#4974).

Thanks for the tests. They pass on my machine. I also re-run the CI tests so that they pass.

@archmoj
Copy link
Contributor

@archmoj archmoj commented Oct 1, 2020

Nicely done. 💃

@archmoj archmoj merged commit 5c9c60b into plotly:master Oct 1, 2020
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants