nbagg: Use OutputArea event to trigger figure close. by QuLogic · Pull Request #18454 · matplotlib/matplotlib · GitHub
Skip to content

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

Merged
tacaswell merged 2 commits into
matplotlib:masterfrom
QuLogic:fix-nbagg-rerun
Sep 14, 2020
Merged

tacaswell merged 2 commits into
matplotlib:masterfrom
QuLogic:fix-nbagg-rerun

Conversation

@QuLogic

@QuLogic QuLogic commented Sep 11, 2020

Copy link
Copy Markdown
Member

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

dopplershift commented Sep 11, 2020

Copy link
Copy Markdown
Contributor

@QuLogic

QuLogic commented Sep 11, 2020

Copy link
Copy Markdown
Member Author

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

@tacaswell

Copy link
Copy Markdown
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

lumberbot-app Bot commented Sep 14, 2020

Copy link
Copy Markdown

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