Skip to content

Commit

Permalink
fix(help panel): prevent duplicated key displays (#5066)
Browse files Browse the repository at this point in the history
* fix(help panel): prevent duplicated key displays

* fix changelog update

* de-dupe key displaus with keymaps

* rename variables for clarity

* change to dict.fromkeys for faster de-duping
  • Loading branch information
TomJGooding authored Nov 7, 2024
1 parent b5c44c2 commit a3fee68
Show file tree
Hide file tree
Showing 5 changed files with 253 additions and 69 deletions.
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/).

## Unreleased

### Fixed

- Fixed duplicated key displays in the help panel https://github.com/Textualize/textual/issues/5037

## [0.85.2] - 2024-11-02

- Fixed broken focus-within https://github.com/Textualize/textual/pull/5190
Expand Down
8 changes: 5 additions & 3 deletions src/textual/widgets/_key_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,13 @@ def render_description(binding: Binding) -> Text:
get_key_display = self.app.get_key_display
for multi_bindings in action_to_bindings.values():
binding, enabled, tooltip = multi_bindings[0]
key_display = " ".join(
get_key_display(binding) for binding, _, _ in multi_bindings
keys_display = " ".join(
dict.fromkeys( # Remove duplicates while preserving order
get_key_display(binding) for binding, _, _ in multi_bindings
)
)
table.add_row(
Text(key_display, style=key_style),
Text(keys_display, style=key_style),
render_description(binding),
)
if namespace != previous_namespace:
Expand Down
Loading

0 comments on commit a3fee68

Please sign in to comment.