From 53314201b08b7ff3758b5d1222c4d214abfb5dd8 Mon Sep 17 00:00:00 2001 From: Hojjat Date: Fri, 11 Sep 2026 11:10:36 -0600 Subject: [PATCH] fix(theme): draw selected label text in the on-accent color --- iced | 2 +- src/theme/style/iced.rs | 4 ++++ src/widget/text_input/input.rs | 13 ++++++++----- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/iced b/iced index 2e12eba5..9ef36c96 160000 --- a/iced +++ b/iced @@ -1 +1 @@ -Subproject commit 2e12eba5cd9ddf9995e113fbc9fa0ebf8f0f0f97 +Subproject commit 9ef36c9604c8eb1d34a4e4f9df438a1da0f9e8a2 diff --git a/src/theme/style/iced.rs b/src/theme/style/iced.rs index 3b0d9794..bd4706c6 100644 --- a/src/theme/style/iced.rs +++ b/src/theme/style/iced.rs @@ -1371,18 +1371,22 @@ impl iced_widget::text::Catalog for Theme { fn style(&self, class: &Self::Class<'_>) -> iced_widget::text::Style { let selected_fill = self.cosmic().accent.base.into(); + let selected_text_color = Some(self.cosmic().on_accent_color().into()); match class { Text::Accent => iced_widget::text::Style { color: Some(self.cosmic().accent_text_color().into()), selected_fill, + selected_text_color, }, Text::Default => iced_widget::text::Style { color: None, selected_fill, + selected_text_color, }, Text::Color(c) => iced_widget::text::Style { color: Some(*c), selected_fill, + selected_text_color, }, Text::Custom(f) => f(self), } diff --git a/src/widget/text_input/input.rs b/src/widget/text_input/input.rs index 07c0714f..9cf4b2e3 100644 --- a/src/widget/text_input/input.rs +++ b/src/widget/text_input/input.rs @@ -2903,14 +2903,17 @@ pub fn draw<'a, Message>( effective_alignment(state.value.raw()), ); - if cursors.is_empty() { - renderer.with_translation(Vector::ZERO, |_| {}); - } else { - renderer.with_translation(Vector::new(alignment_offset - offset, 0.0), |renderer| { + let shift = Vector::new(alignment_offset - offset, 0.0); + let fill_cursors = |renderer: &mut crate::Renderer| { + renderer.with_translation(shift, |renderer| { for (quad, color) in &cursors { renderer.fill_quad(*quad, *color); } }); + }; + + if !is_selecting { + fill_cursors(renderer); } let bounds = Rectangle { @@ -2946,7 +2949,7 @@ pub fn draw<'a, Message>( // Redraw the same text in the selected color, clipped to the selection quads, // so glyph shaping and positioning stay identical to the unselected pass. if is_selecting { - let shift = Vector::new(alignment_offset - offset, 0.0); + fill_cursors(renderer); for (quad, _) in &cursors { renderer.with_layer(quad.bounds + shift, |renderer| { renderer.fill_text(