fix: use selectedForeground's computer colour (or theme's selectedForeground value) for the colour of text in permission selection (resolves #7246) (#7251)

This commit is contained in:
Ariane Emory 2026-01-07 15:45:30 -05:00 committed by GitHub
commit 03eabb10e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 5 deletions

View file

@ -102,15 +102,16 @@ type Theme = ThemeColors & {
thinkingOpacity: number
}
export function selectedForeground(theme: Theme): RGBA {
export function selectedForeground(theme: Theme, bg?: RGBA): RGBA {
// If theme explicitly defines selectedListItemText, use it
if (theme._hasSelectedListItemText) {
return theme.selectedListItemText
}
// For transparent backgrounds, calculate contrast based on primary color
// For transparent backgrounds, calculate contrast based on the actual bg (or fallback to primary)
if (theme.background.a === 0) {
const { r, g, b } = theme.primary
const targetColor = bg ?? theme.primary
const { r, g, b } = targetColor
const luminance = 0.299 * r + 0.587 * g + 0.114 * b
return luminance > 0.5 ? RGBA.fromInts(0, 0, 0) : RGBA.fromInts(255, 255, 255)
}