textual: `pop_screen()` triggering randomly after hoovering buttons under heavy load

I noticed strange behavior while hoovering very fast on many buttons. pop_screen is being triggered ramdomly only under heavy load on my computer (used stress command). Tried same thing with push_screen but works fine. Example used in video:

from __future__ import annotations

from textual import on
from textual.app import App, ComposeResult
from textual.binding import Binding
from textual.screen import Screen, ScreenResultType
from textual.widgets import Button
from textual.containers import Horizontal


class MyApp(App):

    def compose(self) -> ComposeResult:
        yield Button("next screen", variant="success")

    @on(Button.Pressed)
    def next_screen(self):
        self.app.push_screen(Screen2())


class Screen2(Screen[ScreenResultType]):
    BINDINGS = [Binding("escape", "other_screen", "next")]

    def compose(self) -> ComposeResult:
        with Horizontal():
            yield Button("1", variant="success")
            yield Button("2", variant="primary")
            yield Button("3", variant="error")
            yield Button("4", variant="success")
            yield Button("5", variant="primary")
            yield Button("6", variant="error")

    def action_other_screen(self):
        self.app.pop_screen()

MyApp().run()

Since github is accepting files under 10MB im linking video: https://drive.google.com/file/d/1qG4SCLF-0-HXDOMNLBCrGF4lFM7Lxlxj/view?usp=drivesdk

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (8 by maintainers)

Most upvoted comments

@matkudela Could you try running with TEXTUAL_DEBUG=1 to reproduce the issue, then sending us the keys.log file that it generates.