From 8b9b19195d02f104b9fc51805d07ea6ca2c83503 Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Thu, 7 Dec 2023 13:19:03 -0500 Subject: [PATCH] Fix bug with how characters limits are being displayed --- crates/feedback2/src/feedback_modal.rs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/crates/feedback2/src/feedback_modal.rs b/crates/feedback2/src/feedback_modal.rs index c61d17d63c..1b746e1f1f 100644 --- a/crates/feedback2/src/feedback_modal.rs +++ b/crates/feedback2/src/feedback_modal.rs @@ -256,12 +256,6 @@ impl Render for FeedbackModal { }; let valid_character_count = FEEDBACK_CHAR_LIMIT.contains(&self.character_count); - let characters_remaining = - if valid_character_count || self.character_count > *FEEDBACK_CHAR_LIMIT.end() { - *FEEDBACK_CHAR_LIMIT.end() as i32 - self.character_count as i32 - } else { - self.character_count as i32 - *FEEDBACK_CHAR_LIMIT.start() as i32 - }; let allow_submission = valid_character_count && valid_email_address && !self.pending_submission; @@ -318,14 +312,14 @@ impl Render for FeedbackModal { .child( div().child( Label::new( - if !valid_character_count && characters_remaining < 0 { - "Feedback must be at least 10 characters.".to_string() - } else if !valid_character_count && characters_remaining > 5000 { - "Feedback must be less than 5000 characters.".to_string() + if self.character_count < *FEEDBACK_CHAR_LIMIT.start() { + format!("Feedback must be at least {} characters.", FEEDBACK_CHAR_LIMIT.start()) + } else if self.character_count > *FEEDBACK_CHAR_LIMIT.end() { + format!("Feedback must be less than {} characters.", FEEDBACK_CHAR_LIMIT.end()) } else { format!( "Characters: {}", - characters_remaining + *FEEDBACK_CHAR_LIMIT.end() - self.character_count ) } )