diff --git a/src/textual/screen.py b/src/textual/screen.py index be09b66e7c..d58525d3bc 100644 --- a/src/textual/screen.py +++ b/src/textual/screen.py @@ -976,17 +976,6 @@ def _forward_event(self, event: events.Event) -> None: else: widget._forward_event(event._apply_offset(-region.x, -region.y)) - elif isinstance(event, (events.MouseScrollDown, events.MouseScrollUp)): - try: - widget, _region = self.get_widget_at(event.x, event.y) - except errors.NoWidget: - return - scroll_widget = widget - if scroll_widget is not None: - if scroll_widget is self: - self.post_message(event) - else: - scroll_widget._forward_event(event) else: self.post_message(event) diff --git a/tests/test_screens.py b/tests/test_screens.py index e5ddacb4d7..2163a715ef 100644 --- a/tests/test_screens.py +++ b/tests/test_screens.py @@ -6,10 +6,10 @@ from textual import work from textual.app import App, ComposeResult, ScreenStackError -from textual.events import MouseMove +from textual.events import MouseMove, MouseScrollDown, MouseScrollUp from textual.geometry import Offset from textual.screen import Screen -from textual.widgets import Button, Input, Label +from textual.widgets import Button, DataTable, Input, Label from textual.worker import NoActiveWorker skip_py310 = pytest.mark.skipif( @@ -304,6 +304,25 @@ async def key_p(self) -> None: app.bottom.dismiss() +async def test_dismiss_action(): + class ConfirmScreen(Screen[bool]): + BINDINGS = [("y", "dismiss(True)", "Dismiss")] + + class MyApp(App[None]): + bingo = False + + def on_mount(self) -> None: + self.push_screen(ConfirmScreen(), callback=self.callback) + + def callback(self, result: bool) -> None: + self.bingo = result + + app = MyApp() + async with app.run_test() as pilot: + await pilot.press("y") + assert app.bingo + + async def test_switch_screen_no_op(): """Regression test for https://github.com/Textualize/textual/issues/2650"""