Skip to content

Commit 813aeea

Browse files
authored
Merge pull request #6329 from Textualize/fix-triple-clicks
fix triple clicks
2 parents e1225f3 + d842410 commit 813aeea

File tree

6 files changed

+32
-10
lines changed

6 files changed

+32
-10
lines changed

CHANGELOG.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,21 @@ 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
8+
## [7.3.0] - 2026-01-15
99

10-
### Changed
10+
### Fixed
11+
12+
- Fixed triple click on command palette raising an exception https://github.com/Textualize/textual/pull/6329
1113

12-
- Allow `Sparkline` to be of any height, not just 1 https://github.com/Textualize/textual/pull/6171
13-
-
1414
### Added
1515

1616
- Added `DOM.query_one_optional`
17+
- Added `default` parameter to `get_component_rich_style` get_component_rich_style
1718

1819
### Changed
1920

2021
- Added super+c (command on mac) alternative bindings for copy, for terminals that support it (Ghostty does)
22+
- Allow `Sparkline` to be of any height, not just 1 https://github.com/Textualize/textual/pull/6171
2123

2224
## [7.2.0] - 2026-01-11
2325

@@ -3320,6 +3322,7 @@ https://textual.textualize.io/blog/2022/11/08/version-040/#version-040
33203322
- New handler system for messages that doesn't require inheritance
33213323
- Improved traceback handling
33223324

3325+
[7.3.0]: https://github.com/Textualize/textual/compare/v7.2.0...v7.3.0
33233326
[7.2.0]: https://github.com/Textualize/textual/compare/v7.1.0...v7.2.0
33243327
[7.1.0]: https://github.com/Textualize/textual/compare/v7.0.3...v7.1.0
33253328
[7.0.3]: https://github.com/Textualize/textual/compare/v7.0.2...v7.0.3

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "textual"
3-
version = "7.2.0"
3+
version = "7.3.0"
44
homepage = "https://github.com/Textualize/textual"
55
repository = "https://github.com/Textualize/textual"
66
documentation = "https://textual.textualize.io/"

src/textual/command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ class CommandPalette(SystemModalScreen[None]):
524524

525525
AUTO_FOCUS = "CommandInput"
526526

527-
COMPONENT_CLASSES: ClassVar[set[str]] = {
527+
COMPONENT_CLASSES: ClassVar[set[str]] = Screen.COMPONENT_CLASSES | {
528528
"command-palette--help-text",
529529
"command-palette--highlight",
530530
}

src/textual/dom.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import rich.repr
2727
from rich.highlighter import ReprHighlighter
28+
from rich.style import NULL_STYLE as RICH_NULL_STYLE
2829
from rich.style import Style
2930
from rich.text import Text
3031
from rich.tree import Tree
@@ -1072,7 +1073,9 @@ def text_style(self) -> Style:
10721073
@property
10731074
def selection_style(self) -> Style:
10741075
"""The style of selected text."""
1075-
style = self.screen.get_component_rich_style("screen--selection")
1076+
style = self.screen.get_component_rich_style(
1077+
"screen--selection", default=RICH_NULL_STYLE
1078+
)
10761079
return style
10771080

10781081
@property

src/textual/visual.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from rich.measure import Measurement
1111
from rich.protocol import is_renderable, rich_cast
1212
from rich.segment import Segment
13+
from rich.style import NULL_STYLE as RICH_NULL_STYLE
1314
from rich.style import Style as RichStyle
1415
from rich.text import Text
1516

@@ -219,7 +220,9 @@ def to_strips(
219220
selection = widget.text_selection
220221
if selection is not None:
221222
selection_style: Style | None = Style.from_rich_style(
222-
widget.screen.get_component_rich_style("screen--selection")
223+
widget.screen.get_component_rich_style(
224+
"screen--selection", default=RICH_NULL_STYLE
225+
)
223226
)
224227
else:
225228
selection_style = None

src/textual/widget.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,19 +1140,32 @@ def get_child_by_type(self, expect_type: type[ExpectType]) -> ExpectType:
11401140
return child
11411141
raise NoMatches(f"No immediate child of type {expect_type}; {self._nodes}")
11421142

1143-
def get_component_rich_style(self, *names: str, partial: bool = False) -> Style:
1143+
def get_component_rich_style(
1144+
self, *names: str, partial: bool = False, default: Style | None = None
1145+
) -> Style:
11441146
"""Get a *Rich* style for a component.
11451147
11461148
Args:
11471149
names: Names of components.
11481150
partial: Return a partial style (not combined with parent).
1151+
default: A Style to return if any component style doesn't exist.
1152+
1153+
Raises:
1154+
KeyError: If a component style doesn't exist, and no `default` is provided.
11491155
11501156
Returns:
11511157
A Rich style object.
11521158
"""
11531159

11541160
if names not in self._rich_style_cache:
1155-
component_styles = self.get_component_styles(*names)
1161+
if default is None:
1162+
component_styles = self.get_component_styles(*names)
1163+
else:
1164+
try:
1165+
component_styles = self.get_component_styles(*names)
1166+
except KeyError:
1167+
return default
1168+
11561169
style = component_styles.rich_style
11571170
text_opacity = component_styles.text_opacity
11581171
if text_opacity < 1 and style.bgcolor is not None:

0 commit comments

Comments
 (0)