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

Fix links #4540

Merged
merged 4 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -1985,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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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/"
Expand Down
8 changes: 7 additions & 1 deletion src/textual/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
24 changes: 24 additions & 0 deletions tests/test_links.py
Original file line number Diff line number Diff line change
@@ -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"]
Loading