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

Hiding a TextArea while mouse-based selection is happening can trap the cursor #4292

Closed
davep opened this issue Mar 13, 2024 · 1 comment · Fixed by #4295
Closed

Hiding a TextArea while mouse-based selection is happening can trap the cursor #4292

davep opened this issue Mar 13, 2024 · 1 comment · Fixed by #4295
Assignees
Labels
bug Something isn't working Task

Comments

@davep
Copy link
Contributor

davep commented Mar 13, 2024

Initially discovered and reported in a comment in #4274 by @TomJGooding

Somewhat following on from #4274, although very likely an easier fix (I think it just needs a Hide handler to release the mouse and do any other housekeeping necessary to TextArea selection), if you start a mouse selection within TextArea and then hide the TextArea, the mouse will be trapped and won't respond anywhere else.

To illustrate:

from pathlib import Path
from textual.app import App, ComposeResult
from textual.widgets import Collapsible, TextArea


class GreedyScrollbarApp(App[None]):
    BINDINGS = [("f1", "collapse")]

    CSS = """
    TextArea {
        height: 10;
    }
    """

    def compose(self) -> ComposeResult:
        for n in range(5):
            with Collapsible(title=f"This is collapsible #{n}", collapsed=bool(n)):
                yield TextArea(Path(__file__).read_text(), language="python")

    def action_collapse(self) -> None:
        target.collapsed = not (target := self.query(Collapsible).first()).collapsed


if __name__ == "__main__":
    GreedyScrollbarApp().run()

Start a mouse selection in the first TextArea, press F1 while still selecting with the mouse, then notice nothing else will respond to mouse clicks.

@davep davep added bug Something isn't working Task labels Mar 13, 2024
@davep davep self-assigned this Mar 14, 2024
davep added a commit to davep/textual-sandbox that referenced this issue Mar 14, 2024
davep added a commit to davep/textual that referenced this issue Mar 14, 2024
Copy link

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Task
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant