From 7ec7a37098a2ac633b75e6c0844f8f13b74a376e Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Tue, 18 Aug 2026 04:02:13 -0400 Subject: [PATCH] Fix ResizeEvent handling for TextBox A `ResizeEvent` is not a `LocationEvent` subclass, so it does not need to be reparented to the correct `Axes`. Fixes #32222 --- lib/matplotlib/tests/test_widgets.py | 4 +++- lib/matplotlib/widgets.py | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/tests/test_widgets.py b/lib/matplotlib/tests/test_widgets.py index 03146615aac8..1aa6b70e7790 100644 --- a/lib/matplotlib/tests/test_widgets.py +++ b/lib/matplotlib/tests/test_widgets.py @@ -4,7 +4,7 @@ from unittest import mock import matplotlib as mpl -from matplotlib.backend_bases import DrawEvent, KeyEvent, MouseEvent +from matplotlib.backend_bases import DrawEvent, KeyEvent, MouseEvent, ResizeEvent import matplotlib.colors as mcolors import matplotlib.widgets as widgets import matplotlib.pyplot as plt @@ -1097,6 +1097,8 @@ def test_TextBox(ax, toolbar): assert text_change_event.call_count == 3 + ResizeEvent("resize_event", ax.figure.canvas)._process() # smoke test + def test_RadioButtons(ax): radio = widgets.RadioButtons(ax, ('Radio 1', 'Radio 2', 'Radio 3')) diff --git a/lib/matplotlib/widgets.py b/lib/matplotlib/widgets.py index bb60513f832f..daec97f42ce6 100644 --- a/lib/matplotlib/widgets.py +++ b/lib/matplotlib/widgets.py @@ -1718,7 +1718,6 @@ def _click(self, event): self.cursor_index = self.text_disp._char_index_at(event.x) self._rendercursor() - @_call_with_reparented_event def _resize(self, event): self.stop_typing()