From 094611a2ae56f1c2d872fe56f58086e4f1b615fc Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Tue, 10 Dec 2024 19:01:35 +0800 Subject: [PATCH] input: Avoid handle `up`, `down` in Input single line mode. (#485) --- crates/ui/src/input/input.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/ui/src/input/input.rs b/crates/ui/src/input/input.rs index 2f5589ff..05f12d55 100644 --- a/crates/ui/src/input/input.rs +++ b/crates/ui/src/input/input.rs @@ -1177,14 +1177,16 @@ impl Render for TextInput { .on_action(cx.listener(Self::delete_to_end_of_line)) .on_action(cx.listener(Self::enter)) }) - .on_action(cx.listener(Self::up)) - .on_action(cx.listener(Self::down)) .on_action(cx.listener(Self::left)) .on_action(cx.listener(Self::right)) - .on_action(cx.listener(Self::select_up)) - .on_action(cx.listener(Self::select_down)) .on_action(cx.listener(Self::select_left)) .on_action(cx.listener(Self::select_right)) + .when(self.multi_line, |this| { + this.on_action(cx.listener(Self::up)) + .on_action(cx.listener(Self::down)) + .on_action(cx.listener(Self::select_up)) + .on_action(cx.listener(Self::select_down)) + }) .on_action(cx.listener(Self::select_all)) .on_action(cx.listener(Self::select_to_home)) .on_action(cx.listener(Self::select_to_end))