Skip to content

Commit

Permalink
Ensure that the mouse is released when a TextArea gets hidden
Browse files Browse the repository at this point in the history
  • Loading branch information
davep committed Mar 14, 2024
1 parent c7370f3 commit 5aa05f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Fixed `OptionList.OptionHighlighted` leaking out of `Select` https://github.com/Textualize/textual/issues/4224
- Fixed `Tab` enable/disable messages leaking into `TabbedContent` https://github.com/Textualize/textual/issues/4233
- Fixed a style leak from `TabbedContent` https://github.com/Textualize/textual/issues/4232
- Fixed the mouse not being released when hiding a `TextArea` while mouse selection is happening https://github.com/Textualize/textual/issues/4292

### Changed

Expand Down
10 changes: 9 additions & 1 deletion src/textual/widgets/_text_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -1498,13 +1498,21 @@ async def _on_mouse_move(self, event: events.MouseMove) -> None:
selection_start, _ = self.selection
self.selection = Selection(selection_start, target)

async def _on_mouse_up(self, event: events.MouseUp) -> None:
def _end_mouse_selection(self) -> None:
"""Finalize the selection that has been made using the mouse."""
self._selecting = False
self.release_mouse()
self.record_cursor_width()
self._restart_blink()

async def _on_mouse_up(self, event: events.MouseUp) -> None:
"""Finalize the selection that has been made using the mouse."""
self._end_mouse_selection()

async def _on_hide(self, event: events.Hide) -> None:
"""Finalize the selection that has been made using the mouse when thew widget is hidden."""
self._end_mouse_selection()

async def _on_paste(self, event: events.Paste) -> None:
"""When a paste occurs, insert the text from the paste event into the document."""
if self.read_only:
Expand Down

0 comments on commit 5aa05f3

Please sign in to comment.