mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
todomvc example: Disallow entering empty items (#3193)
It was possible to add an empty entry by typing whitespace into the text field. This fixes that by trimming the string *before* we check whether it's empty.
This commit is contained in:
parent
b82021c455
commit
86b6cb4949
@ -45,9 +45,10 @@ impl Component for App {
|
||||
fn update(&mut self, _ctx: &Context<Self>, msg: Self::Message) -> bool {
|
||||
match msg {
|
||||
Msg::Add(description) => {
|
||||
let description = description.trim();
|
||||
if !description.is_empty() {
|
||||
let entry = Entry {
|
||||
description: description.trim().to_string(),
|
||||
description: description.to_string(),
|
||||
completed: false,
|
||||
editing: false,
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user