Skip to content

Commit

Permalink
fix multi keys
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed May 22, 2024
1 parent 915b769 commit 7e15b9d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/).

## [0.63.1] - 2024-05-22

### Fixed

- Fixed display of multiple bindings

## [0.63.0] - 2024-05-22

### Fixed
Expand Down
13 changes: 12 additions & 1 deletion src/textual/widgets/_footer.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
from __future__ import annotations

from collections import defaultdict

import rich.repr
from rich.text import Text

from textual.binding import Binding

from ..app import ComposeResult
from ..containers import ScrollableContainer
from ..reactive import reactive
Expand Down Expand Up @@ -132,8 +136,15 @@ def compose(self) -> ComposeResult:
for (_, binding, enabled) in self.screen.active_bindings.values()
if binding.show
]
self.styles.grid_size_columns = len(bindings)
action_to_bindings: defaultdict[str, list[tuple[Binding, bool]]] = defaultdict(
list
)
for binding, enabled in bindings:
action_to_bindings[binding.action].append((binding, enabled))

self.styles.grid_size_columns = len(bindings)
for multi_bindings in action_to_bindings.values():
binding, enabled = multi_bindings[0]
yield FooterKey(
binding.key,
binding.key_display or self.app.get_key_display(binding.key),
Expand Down
5 changes: 5 additions & 0 deletions tests/snapshot_tests/test_snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -1264,3 +1264,8 @@ def test_dynamic_bindings(snap_compare):
def test_grid_gutter(snap_compare):
# https://github.com/Textualize/textual/issues/4522
assert snap_compare(SNAPSHOT_APPS_DIR / "grid_gutter.py")


def test_multi_keys(snap_compare):
# https://github.com/Textualize/textual/issues/4542
assert snap_compare(SNAPSHOT_APPS_DIR / "multi_keys.py")

0 comments on commit 7e15b9d

Please sign in to comment.