Skip to content

Commit

Permalink
text: Always use default text format for empty text
Browse files Browse the repository at this point in the history
This behavior is observable in Flash Player, because the caret in empty
input text fields uses this format to be rendered.
  • Loading branch information
kjarosh committed Dec 19, 2024
1 parent c1a4df4 commit 4fec150
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core/src/html/text_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,11 @@ impl FormatSpans {

pub fn set_default_format(&mut self, tf: TextFormat) {
self.default_format = tf.mix_with(self.default_format.clone());

// Empty text always gets the default format.
if self.text.is_empty() {
self.spans = vec![TextSpan::with_length_and_format(0, &self.default_format)];
}
}

pub fn hide_text(&mut self) {
Expand Down

0 comments on commit 4fec150

Please sign in to comment.