diff --git a/core/.changelog.d/3859.fixed b/core/.changelog.d/3859.fixed new file mode 100644 index 000000000..06b0f8239 --- /dev/null +++ b/core/.changelog.d/3859.fixed @@ -0,0 +1 @@ +Fix persistent word when going to previous word during recovery process. diff --git a/core/embed/rust/src/ui/model_mercury/component/keyboard/mnemonic.rs b/core/embed/rust/src/ui/model_mercury/component/keyboard/mnemonic.rs index 00755202a..e9ee60cc5 100644 --- a/core/embed/rust/src/ui/model_mercury/component/keyboard/mnemonic.rs +++ b/core/embed/rust/src/ui/model_mercury/component/keyboard/mnemonic.rs @@ -1,10 +1,7 @@ use crate::{ strutil::TString, ui::{ - component::{ - maybe::paint_overlapping, Component, Event, EventCtx, Label, Maybe, Swipe, - SwipeDirection, - }, + component::{maybe::paint_overlapping, Component, Event, EventCtx, Label, Maybe}, geometry::{Alignment, Grid, Insets, Rect}, model_mercury::{ component::{Button, ButtonMsg}, @@ -35,8 +32,6 @@ pub struct MnemonicKeyboard { keypad_area: Rect, /// Key buttons. keys: [Button; MNEMONIC_KEY_COUNT], - /// Swipe controller - allowing for going to the previous word. - swipe: Swipe, /// Whether going back is allowed (is not on the very first word). can_go_back: bool, } @@ -78,7 +73,6 @@ where input: Maybe::new(theme::BG, input, !prompt_visible), keypad_area: Rect::zero(), keys, - swipe: Swipe::new().right(), can_go_back, } } @@ -136,7 +130,6 @@ where let input_area = input_area.inset(Insets::left(BACK_BUTTON_RIGHT_EXPAND)); let keyboard_grid = Grid::new(keypad_area, 3, 3).with_spacing(theme::KEYBOARD_SPACING); - self.swipe.place(bounds); self.prompt.place(prompt_area); self.erase.place(back_btn_area); self.back.place(back_btn_area); @@ -149,14 +142,11 @@ where } fn event(&mut self, ctx: &mut EventCtx, event: Event) -> Option { - // Back button or swipe will cause going back to the previous word when allowed. + // Back button will cause going back to the previous word when allowed. if self.can_go_back { if let Some(ButtonMsg::Clicked) = self.back.event(ctx, event) { return Some(MnemonicKeyboardMsg::Previous); } - if let Some(SwipeDirection::Right) = self.swipe.event(ctx, event) { - return Some(MnemonicKeyboardMsg::Previous); - } } match self.input.event(ctx, event) { diff --git a/core/src/apps/management/recovery_device/layout.py b/core/src/apps/management/recovery_device/layout.py index 7de6c75bc..d602b98a8 100644 --- a/core/src/apps/management/recovery_device/layout.py +++ b/core/src/apps/management/recovery_device/layout.py @@ -27,14 +27,14 @@ async def request_mnemonic( await button_request("mnemonic", code=ButtonRequestType.MnemonicInput) - # Allowing to go back to previous words, therefore cannot use just loop over range(word_count) + # Pre-allocate the list to enable going back and overwriting words. words: list[str] = [""] * word_count i = 0 - while True: - # All the words have been entered - if i >= word_count: - break + def all_words_entered() -> bool: + return i >= word_count + + while not all_words_entered(): # Prefilling the previously inputted word in case of going back word = await request_word( i, @@ -43,9 +43,10 @@ async def request_mnemonic( prefill_word=words[i], ) - # User has decided to go back if not word: + # User has decided to go back if i > 0: + words[i] = "" i -= 1 continue diff --git a/tests/click_tests/recovery.py b/tests/click_tests/recovery.py index 108214929..2a630e2ce 100644 --- a/tests/click_tests/recovery.py +++ b/tests/click_tests/recovery.py @@ -222,7 +222,7 @@ def enter_seed_previous_correct( if go_back: go_back = False - if debug.model in (models.T2T1, models.T3T1): + if debug.model in (models.T2T1,): debug.swipe_right(wait=True) for _ in range(len(bad_word)): debug.click(buttons.RECOVERY_DELETE, wait=True) @@ -237,6 +237,10 @@ def enter_seed_previous_correct( while layout.get_middle_choice() not in DELETE_BTN_TEXTS: layout = debug.press_left(wait=True) layout = debug.press_middle(wait=True) + elif debug.model in (models.T3T1,): + debug.click(buttons.RECOVERY_DELETE, wait=True) # Top-left + for _ in range(len(bad_word)): + debug.click(buttons.RECOVERY_DELETE, wait=True) continue if i in bad_indexes: