Skip to content

Commit a3fee68

Browse files
authored
fix(help panel): prevent duplicated key displays (#5066)
* 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
1 parent b5c44c2 commit a3fee68

File tree

5 files changed

+253
-69
lines changed

5 files changed

+253
-69
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8+
## Unreleased
9+
10+
### Fixed
11+
12+
- Fixed duplicated key displays in the help panel https://github.com/Textualize/textual/issues/5037
13+
814
## [0.85.2] - 2024-11-02
915

1016
- Fixed broken focus-within https://github.com/Textualize/textual/pull/5190

src/textual/widgets/_key_panel.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,13 @@ def render_description(binding: Binding) -> Text:
9090
get_key_display = self.app.get_key_display
9191
for multi_bindings in action_to_bindings.values():
9292
binding, enabled, tooltip = multi_bindings[0]
93-
key_display = " ".join(
94-
get_key_display(binding) for binding, _, _ in multi_bindings
93+
keys_display = " ".join(
94+
dict.fromkeys( # Remove duplicates while preserving order
95+
get_key_display(binding) for binding, _, _ in multi_bindings
96+
)
9597
)
9698
table.add_row(
97-
Text(key_display, style=key_style),
99+
Text(keys_display, style=key_style),
98100
render_description(binding),
99101
)
100102
if namespace != previous_namespace:

0 commit comments

Comments
 (0)