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

nbagg: Use OutputArea event to trigger figure close. #18454

Merged
merged 2 commits into from
Sep 14, 2020

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Sep 11, 2020

PR Summary

When converting from jQuery to vanilla JavaScript, the trigger for the figure closure was set to a non-existent event name, as the 'remove' event is jQuery-specific.

As there is no DOM node removal event (unless using MutationObserver), connect this handler to the notebook's Cell OutputArea's 'cleared' event. This is triggered both by re-running a cell, and by using the Clear Output menu option.

Fixes #18447.

PR Checklist

  • [n/a] Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (run flake8 on changed files to check).
  • [n/a] New features are documented, with examples if plot related.
  • [n/a] Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • Conforms to Matplotlib style conventions (install flake8-docstrings and pydocstyle<4 and run flake8 --docstring-convention=all).
  • [n/a] New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • [n/a] API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).

When converting from jQuery to vanilla JavaScript, the trigger for the
figure closure was set to a non-existent event name, as the 'remove'
event is jQuery-specific.

As there is no DOM node removal event (unless using MutationObserver),
connect this handler to the notebook's `Cell` `OutputArea`'s 'cleared'
event. This is triggered both by re-running a cell, and by using the
Clear Output menu option.

Fixes matplotlib#18447.
@QuLogic QuLogic added this to the v3.3.2 milestone Sep 11, 2020
@dopplershift
Copy link
Contributor

dopplershift commented Sep 11, 2020

Unfortunately, the test failures look real... Ah, I see it's just the current nbconvert problem.

@QuLogic
Copy link
Member Author

QuLogic commented Sep 11, 2020

I pushed a (hopefully safe) pin for nbconvert, so we can fix CI as well.

@tacaswell
Copy link
Member

Checked this manually and it work is both brave (chrome-derivative) and firefox.

@tacaswell tacaswell merged commit f24a1e2 into matplotlib:master Sep 14, 2020
@lumberbot-app
Copy link

lumberbot-app bot commented Sep 14, 2020

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
$ git checkout v3.3.x
$ git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
$ git cherry-pick -m1 f24a1e250de15e79b0212960aba2c61386bbeb16
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
$ git commit -am 'Backport PR #18454: nbagg: Use OutputArea event to trigger figure close.'
  1. Push to a named branch :
git push YOURFORK v3.3.x:auto-backport-of-pr-18454-on-v3.3.x
  1. Create a PR against branch v3.3.x, I would have named this PR:

"Backport PR #18454 on branch v3.3.x"

And apply the correct labels and milestones.

Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon!

If these instruction are inaccurate, feel free to suggest an improvement.

tacaswell added a commit to tacaswell/matplotlib that referenced this pull request Sep 14, 2020
FIX: Use OutputArea event to trigger figure close in nbagg
@tacaswell tacaswell mentioned this pull request Sep 14, 2020
@QuLogic QuLogic deleted the fix-nbagg-rerun branch September 14, 2020 19:13
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.

nbagg: Closing a figure from the notebook does not close the python figure
4 participants