If values for current_text and prev_text are unchanged, filter out the previous value.

This commit is contained in:
Nolan Darilek 2021-05-20 12:34:45 -05:00
parent 9fe465cc4a
commit 265190a892

View file

@ -345,9 +345,16 @@ impl WidgetInfo {
#[allow(clippy::needless_pass_by_value)] #[allow(clippy::needless_pass_by_value)]
pub fn text_edit(prev_text_value: impl ToString, text_value: impl ToString) -> Self { pub fn text_edit(prev_text_value: impl ToString, text_value: impl ToString) -> Self {
let text_value = text_value.to_string();
let prev_text_value = prev_text_value.to_string();
let prev_text_value = if text_value == prev_text_value {
None
} else {
Some(prev_text_value)
};
Self { Self {
current_text_value: Some(text_value.to_string()), current_text_value: Some(text_value.to_string()),
prev_text_value: Some(prev_text_value.to_string()), prev_text_value,
..Self::new(WidgetType::TextEdit) ..Self::new(WidgetType::TextEdit)
} }
} }