From 4c70b7966397464cd0a6e93723b4edbfb0a430ce Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Wed, 27 Jun 2018 13:32:39 -0700 Subject: [PATCH] LinearLayout: fix focus after removing child --- src/views/linear_layout.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/views/linear_layout.rs b/src/views/linear_layout.rs index b6fd446..92ec4ab 100644 --- a/src/views/linear_layout.rs +++ b/src/views/linear_layout.rs @@ -181,6 +181,10 @@ impl LinearLayout { pub fn remove_child(&mut self, i: usize) -> Option> { if i < self.children.len() { self.invalidate(); + + if self.focus > i { + self.focus -= 1; + } Some(self.children.remove(i).view) } else { None