From b1c8bb62b1d9728b563931ccd2374c23a5ad5ba8 Mon Sep 17 00:00:00 2001 From: itsscb Date: Wed, 28 Aug 2024 14:03:14 +0200 Subject: [PATCH] fix(frontend): adds debug code to fix no input possible on Mobile --- frontend/src/pages/home.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/frontend/src/pages/home.rs b/frontend/src/pages/home.rs index 4de5449..b33a503 100644 --- a/frontend/src/pages/home.rs +++ b/frontend/src/pages/home.rs @@ -138,6 +138,9 @@ pub fn Home() -> Html { let word: UseStateHandle = use_state(String::new); let loading: UseStateHandle = use_state(|| true); let curr_index: UseStateHandle = use_state(|| 0usize); + + // TODO: Remove DEBUG + let inp: UseStateHandle = use_state(String::new); let length = use_state(|| 0usize); let submitted_words: UseStateHandle>>> = @@ -308,6 +311,9 @@ pub fn Home() -> Html { let input_values = input_values.clone(); let node_refs = node_refs.clone(); + // TODO: Remove DEBUG + let inp = inp.clone(); + Callback::from(move |e: InputEvent| { let event = e.dyn_into::().ok(); if let Some(e) = event.as_ref() { @@ -336,6 +342,9 @@ pub fn Home() -> Html { let index = *curr_index; let mut values = (*input_values).clone(); + // TODO: Remove DEBUG + inp.set(k.to_owned()); + if k.len() == 1 && k.chars().all(char::is_alphabetic) { values[index] = k.to_uppercase(); input_values.set(values); @@ -375,6 +384,9 @@ pub fn Home() -> Html {
+ + // TODO: Remove DEBUG +

{(*inp).clone()}

@@ -460,11 +472,11 @@ pub fn Home() -> Html { Callback::from(move |e: FocusEvent| { let target = e.target_unchecked_into::(); - if let Some(index) = target.get_attribute("tabindex") { - if let Ok(i) = index.parse::() { - curr_index.set(i); - } + if let Some(index) = target.get_attribute("tabindex") { + if let Ok(i) = index.parse::() { + curr_index.set(i); } + } }) };