Skip to content

Commit

Permalink
Merge pull request #4540 from Textualize/fix-links
Browse files Browse the repository at this point in the history
Fix links
  • Loading branch information
willmcgugan authored May 22, 2024
2 parents 78d0061 + 33e318d commit c925663
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
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"]

0 comments on commit c925663

Please sign in to comment.