Skip to content

Commit

Permalink
✨ select the first item by default
Browse files Browse the repository at this point in the history
  • Loading branch information
pyaillet committed Dec 27, 2023
1 parent bdbd01f commit 33d15d1
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/components/container_exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ impl Component for ContainerExec {
}

fn teardown(&mut self, t: &mut tui::Tui) -> Result<()> {
t.start();
t.clear()?;
Ok(())
}
Expand Down
3 changes: 3 additions & 0 deletions src/components/containers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions src/components/images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions src/components/networks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/components/volumes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)))?,
},
Expand Down

0 comments on commit 33d15d1

Please sign in to comment.