mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
@@ -5,6 +5,12 @@ 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/).
|
||||
|
||||
## Unreleased
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed a crash when setting keymap before app mount https://github.com/Textualize/textual/issues/5742
|
||||
|
||||
## [3.1.0] - 2025-04-12
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -1818,7 +1818,8 @@ class DOMNode(MessagePump):
|
||||
See [actions](/guide/actions#dynamic-actions) for how to use this method.
|
||||
|
||||
"""
|
||||
self.screen.refresh_bindings()
|
||||
if self._is_mounted:
|
||||
self.screen.refresh_bindings()
|
||||
|
||||
async def action_toggle(self, attribute_name: str) -> None:
|
||||
"""Toggle an attribute on the node.
|
||||
|
||||
@@ -192,3 +192,28 @@ async def test_keymap_child_with_different_id_overridden():
|
||||
await pilot.press("i")
|
||||
assert parent_counter == 1
|
||||
assert child_counter == 1
|
||||
|
||||
|
||||
async def test_set_keymap_before_app_mount():
|
||||
"""Ensure we can set the keymap before mount without crash.
|
||||
|
||||
https://github.com/Textualize/textual/issues/5742
|
||||
"""
|
||||
|
||||
worked = False
|
||||
|
||||
class MyApp(App[None]):
|
||||
|
||||
BINDINGS = [Binding(key="x", action="test", id="test")]
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.update_keymap({"test": "y"})
|
||||
|
||||
def action_test(self) -> None:
|
||||
nonlocal worked
|
||||
worked = True
|
||||
|
||||
async with MyApp().run_test() as pilot:
|
||||
await pilot.press("y")
|
||||
assert worked is True
|
||||
|
||||
Reference in New Issue
Block a user