Skip to content

Commit 3767057

Browse files
authored
Ensure cursor visible when no placeholder in Input (#1202)
* Ensure cursor visible when no placeholder in Input * Update CHANGELOG.md
1 parent e0ddea8 commit 3767057

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
3939
- Fixed issues with animation. Now objects of different types may be animated.
4040
- Fixed containers with transparent background not showing borders https://github.com/Textualize/textual/issues/1175
4141
- Fixed auto-width in horizontal containers https://github.com/Textualize/textual/pull/1155
42+
- Fixed Input cursor invisible when placeholder empty https://github.com/Textualize/textual/pull/1202
4243

4344
## [0.4.0] - 2022-11-08
4445

src/textual/widgets/_input.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ def render(self) -> RenderableType:
176176
if self.has_focus:
177177
cursor_style = self.get_component_rich_style("input--cursor")
178178
if self._cursor_visible:
179+
# If the placeholder is empty, there's no characters to stylise
180+
# to make the cursor flash, so use a single space character
181+
if len(placeholder) == 0:
182+
placeholder = Text(" ")
179183
placeholder.stylize(cursor_style, 0, 1)
180184
return placeholder
181185
return _InputRenderable(self, self._cursor_visible)

0 commit comments

Comments
 (0)