From 33d15d1ba7d16e64ee917ff6a19195aa87a490b4 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Aillet Date: Wed, 27 Dec 2023 14:03:26 +0100 Subject: [PATCH] :sparkles: select the first item by default --- src/components/container_exec.rs | 1 - src/components/containers.rs | 3 +++ src/components/images.rs | 3 +++ src/components/networks.rs | 3 +++ src/components/volumes.rs | 3 +++ 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/container_exec.rs b/src/components/container_exec.rs index 7486bfc..94fc96e 100644 --- a/src/components/container_exec.rs +++ b/src/components/container_exec.rs @@ -126,7 +126,6 @@ impl Component for ContainerExec { } fn teardown(&mut self, t: &mut tui::Tui) -> Result<()> { - t.start(); t.clear()?; Ok(()) } diff --git a/src/components/containers.rs b/src/components/containers.rs index 44a1aba..e3b705e 100644 --- a/src/components/containers.rs +++ b/src/components/containers.rs @@ -276,6 +276,9 @@ impl Component for Containers { } }; self.sort(); + if self.state.selected().is_none() { + self.state.select(Some(0)); + } } (Action::Down, Popup::None) => { self.next(); diff --git a/src/components/images.rs b/src/components/images.rs index e3a22c8..6ce013e 100644 --- a/src/components/images.rs +++ b/src/components/images.rs @@ -157,6 +157,9 @@ impl Component for Images { Action::Tick => { self.images = block_on(list_images())?; self.sort(); + if self.state.selected().is_none() { + self.state.select(Some(0)); + } } Action::Down => { self.next(); diff --git a/src/components/networks.rs b/src/components/networks.rs index 7cfbfb6..6856778 100644 --- a/src/components/networks.rs +++ b/src/components/networks.rs @@ -157,6 +157,9 @@ impl Component for Networks { Ok(networks) => { self.networks = networks; self.sort(); + if self.state.selected().is_none() { + self.state.select(Some(0)); + } } Err(e) => self .action_tx diff --git a/src/components/volumes.rs b/src/components/volumes.rs index ce868b8..7dd6dcc 100644 --- a/src/components/volumes.rs +++ b/src/components/volumes.rs @@ -157,6 +157,9 @@ impl Component for Volumes { Ok(volumes) => { self.volumes = volumes; self.sort(); + if self.state.selected().is_none() { + self.state.select(Some(0)); + } } Err(e) => tx.send(Action::Error(format!("Error listing volumes:\n{}", e)))?, },