From c4d8cc2ac19390727e00c787de8fe3918a185015 Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Wed, 22 May 2024 13:53:32 +0100 Subject: [PATCH 1/4] fix --- CHANGELOG.md | 6 +++++- src/textual/app.py | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c2400363db..71de552d6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## [0.63.0] - Unreleased +## [0.63.0] - 2024-05-22 + +### Fixed + +- Fixed actions in links ### Changed diff --git a/src/textual/app.py b/src/textual/app.py index cfdcc67d57..8d05aefd46 100644 --- a/src/textual/app.py +++ b/src/textual/app.py @@ -3175,10 +3175,16 @@ async def _broker_event( return False else: event.stop() + if isinstance(action, str): await self.run_action(action, default_namespace) elif isinstance(action, tuple) and len(action) == 2: - await self.run_action(("", *action), default_namespace) + action_name, action_params = action + namespace, parsed_action, _ = actions.parse(action_name) + await self.run_action( + (namespace, parsed_action, action_params), + default_namespace, + ) elif callable(action): await action() else: From 612d9ec37e77f7e349f6b53c0d79deff3f69731b Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Wed, 22 May 2024 13:54:10 +0100 Subject: [PATCH 2/4] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71de552d6d..b66a10519b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1989,6 +1989,7 @@ https://textual.textualize.io/blog/2022/11/08/version-040/#version-040 - New handler system for messages that doesn't require inheritance - Improved traceback handling +[0.63.0]: https://github.com/Textualize/textual/compare/v0.62.0...v0.63.0 [0.62.0]: https://github.com/Textualize/textual/compare/v0.61.1...v0.62.0 [0.61.1]: https://github.com/Textualize/textual/compare/v0.61.0...v0.61.1 [0.61.0]: https://github.com/Textualize/textual/compare/v0.60.1...v0.61.0 From 3ec7d0c7fea4183b5306b241252e01bc0a30f5ae Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Wed, 22 May 2024 13:54:24 +0100 Subject: [PATCH 3/4] bump --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 25cb9d25f8..40af402d59 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "textual" -version = "0.62.0" +version = "0.63.0" homepage = "https://github.com/Textualize/textual" repository = "https://github.com/Textualize/textual" documentation = "https://textual.textualize.io/" From 33e318df4f9a853c3336a95bf3568e6b56d42dd9 Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Wed, 22 May 2024 14:51:18 +0100 Subject: [PATCH 4/4] test --- tests/test_links.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/test_links.py diff --git a/tests/test_links.py b/tests/test_links.py new file mode 100644 index 0000000000..e88c3f49d4 --- /dev/null +++ b/tests/test_links.py @@ -0,0 +1,24 @@ +from textual.app import App, ComposeResult +from textual.screen import Screen +from textual.widgets import Label + + +async def test_links(): + """Regression test for https://github.com/Textualize/textual/issues/4536""" + messages: list[str] = [] + + class HomeScreen(Screen[None]): + def compose(self) -> ComposeResult: + yield Label("[@click=app.bell_message('hi')]Ring the bell![/]") + + class ScreenNamespace(App[None]): + def get_default_screen(self) -> HomeScreen: + return HomeScreen() + + def action_bell_message(self, message: str) -> None: + nonlocal messages + messages.append(message) + + async with ScreenNamespace().run_test() as pilot: + await pilot.click(offset=(5, 0)) + assert messages == ["hi"]