Skip to content

Commit

Permalink
Merge branch 'main' into fix-footer-ignore-multi-bindings-for-grid-size
Browse files Browse the repository at this point in the history
  • Loading branch information
TomJGooding authored May 23, 2024
2 parents ce00424 + def421f commit 7cb7581
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 20 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- Fixed `Footer` grid size https://github.com/Textualize/textual/pull/4545

## [0.63.2] - 2024-05-23

### Fixed

- Fixed issue with namespaces in links https://github.com/Textualize/textual/pull/4546

## [0.63.1] - 2024-05-22

### Fixed
Expand Down Expand Up @@ -2002,6 +2008,8 @@ 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.2]: https://github.com/Textualize/textual/compare/v0.63.1...v0.63.2
[0.63.1]: https://github.com/Textualize/textual/compare/v0.63.0...v0.63.1
[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
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.63.1"
version = "0.63.2"
homepage = "https://github.com/Textualize/textual"
repository = "https://github.com/Textualize/textual"
documentation = "https://textual.textualize.io/"
Expand Down
19 changes: 9 additions & 10 deletions src/textual/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3038,7 +3038,7 @@ async def on_event(self, event: events.Event) -> None:
await super().on_event(event)

def _parse_action(
self, action: str, default_namespace: DOMNode
self, action: str | ActionParseResult, default_namespace: DOMNode
) -> tuple[DOMNode, str, tuple[object, ...]]:
"""Parse an action.
Expand All @@ -3051,7 +3051,11 @@ def _parse_action(
Returns:
A tuple of (node or None, action name, tuple of parameters).
"""
destination, action_name, params = actions.parse(action)
if isinstance(action, tuple):
destination, action_name, params = action
else:
destination, action_name, params = actions.parse(action)

action_target: DOMNode | None = None
if destination:
if destination not in self._action_targets:
Expand Down Expand Up @@ -3098,14 +3102,9 @@ async def run_action(
Returns:
True if the event has been handled.
"""
if isinstance(action, str):
action_target, action_name, params = self._parse_action(
action, self if default_namespace is None else default_namespace
)
else:
# assert isinstance(action, tuple)
_, action_name, params = action
action_target = self
action_target, action_name, params = self._parse_action(
action, self if default_namespace is None else default_namespace
)

if action_target.check_action(action_name, params):
return await self._dispatch_action(action_target, action_name, params)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_data_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,7 @@ def compose(self) -> ComposeResult:

def on_mount(self) -> None:
table = self.query_one(DataTable)
table.border_title = "[@click=test_link]Border Link[/]"
table.border_title = "[@click=app.test_link]Border Link[/]"

def action_test_link(self) -> None:
self.link_clicked = True
Expand Down
7 changes: 3 additions & 4 deletions tests/test_issue_4248.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ async def test_issue_4248() -> None:
bumps = 0

class ActionApp(App[None]):

def compose(self) -> ComposeResult:
yield Label("[@click]click me and crash[/]", id="nothing")
yield Label("[@click=]click me and crash[/]", id="no-params")
yield Label("[@click=()]click me and crash[/]", id="empty-params")
yield Label("[@click=foobar]click me[/]", id="unknown-sans-parens")
yield Label("[@click=foobar()]click me[/]", id="unknown-with-parens")
yield Label("[@click=bump]click me[/]", id="known-sans-parens")
yield Label("[@click=bump()]click me[/]", id="known-empty-parens")
yield Label("[@click=bump(100)]click me[/]", id="known-with-param")
yield Label("[@click=app.bump]click me[/]", id="known-sans-parens")
yield Label("[@click=app.bump()]click me[/]", id="known-empty-parens")
yield Label("[@click=app.bump(100)]click me[/]", id="known-with-param")

def action_bump(self, by_value: int = 1) -> None:
nonlocal bumps
Expand Down
21 changes: 17 additions & 4 deletions tests/test_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,35 @@
from textual.widgets import Label


async def test_links():
async def test_links() -> None:
"""Regression test for https://github.com/Textualize/textual/issues/4536"""
messages: list[str] = []

class LinkLabel(Label):
def action_bell_message(self, message: str) -> None:
nonlocal messages
messages.append(f"label {message}")

class HomeScreen(Screen[None]):
def compose(self) -> ComposeResult:
yield Label("[@click=app.bell_message('hi')]Ring the bell![/]")
yield LinkLabel("[@click=app.bell_message('foo')]Ring the bell![/]")
yield LinkLabel("[@click=screen.bell_message('bar')]Ring the bell![/]")
yield LinkLabel("[@click=bell_message('baz')]Ring the bell![/]")

def action_bell_message(self, message: str) -> None:
nonlocal messages
messages.append(f"screen {message}")

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)
messages.append(f"app {message}")

async with ScreenNamespace().run_test() as pilot:
await pilot.click(offset=(5, 0))
assert messages == ["hi"]
await pilot.click(offset=(5, 1))
await pilot.click(offset=(5, 2))
assert messages == ["app foo", "screen bar", "label baz"]

0 comments on commit 7cb7581

Please sign in to comment.