-
Notifications
You must be signed in to change notification settings - Fork 7.1k
fix: ensure selected list items are readable with transparent background #4574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Minutes before you submitted this, I'd just submitted an alternate solution by adding an optional selectedListItemText theme element to allow users to explicitly choose a colour for selected list items: #4572 Maybe we should combine our approaches, allowing either my explicit colour selection via selectedListItemText or your automatic selection when an explicit selectedListItemText is nor present in the theme? |
|
@ariane-emory
👍 |
|
No need to apologize! Tackling the problem from both ends and allowing either automatic colour selection or explicit selection is probably more robust than doing either in isolation. I'll try merging your branch into mine and see how it works. |
|
@ariane-emory |
|
merge with #4572. |
| customBorderChars={ | ||
| theme.background.a != 0 | ||
| ? { | ||
| ...EmptyBorder, | ||
| horizontal: "▀", | ||
| } | ||
| : { | ||
| ...EmptyBorder, | ||
| horizontal: " ", | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to the changes added in 23ea8ba, a black line is displayed when backgroundElement is transparent. OpenTUI might not recognize borderColor when it is set to transparent and instead displays it in the default black.

f1dc981 to
3e15a39
Compare
df8bdf9 to
0dd5039
Compare
|
Close this, since #4572 has been merged, |
Fixes: #4369
Summary
Fix unreadable text in selected list items when theme uses background: "none"
Details
When a theme sets "background": "none", the background color resolves to fully transparent. Previously, selected list items used theme.background as the foreground color, making the text invisible. This PR adds a helper that returns a contrasting color (black or white) based on the luminance of theme.
Before:
After: