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.

@archmoj archmoj added status: reviewable bug something broken community community contribution labels Sep 30, 2020
@archmoj archmoj requested a review from antoinerg September 30, 2020 20:10
@alexcjohnson
Copy link
Collaborator

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 October 1, 2020 01:01
@Yook74
Copy link
Author

Yook74 commented Oct 1, 2020

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

@archmoj
Copy link
Contributor

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 commented Oct 1, 2020

Nicely done. 💃

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

Successfully merging this pull request may close these issues.

Using restyle method in updatemenus button removes the modebar
3 participants