Clear hover highlights when navigating with keyboard

Keyboard navigation (arrow keys) did not clear item hover state, causing
items to retain their grey hover background after the mouse left the
window, resulting in multiple items appearing highlighted simultaneously.

Fixes #1865
This commit is contained in:
Gene Wood 2026-06-17 12:33:57 -07:00 committed by Ashley Wulber
parent 7d3487da7b
commit 53a33dbe74

View file

@ -3130,6 +3130,14 @@ impl Tab {
item.pos_opt.get() item.pos_opt.get()
} }
fn dehighlight_all(&mut self) {
if let Some(items) = self.items_opt.as_mut() {
for item in items.iter_mut() {
item.highlighted = false;
}
}
}
pub(crate) fn select_focus_scroll(&mut self) -> Option<AbsoluteOffset> { pub(crate) fn select_focus_scroll(&mut self) -> Option<AbsoluteOffset> {
let items = self.items_opt.as_ref()?; let items = self.items_opt.as_ref()?;
let item = items.get(self.select_focus?)?; let item = items.get(self.select_focus?)?;
@ -3820,6 +3828,7 @@ impl Tab {
} }
} }
Message::ItemDown => { Message::ItemDown => {
self.dehighlight_all();
if let Some(edit_location) = &mut self.edit_location { if let Some(edit_location) = &mut self.edit_location {
edit_location.select(true); edit_location.select(true);
} else if self.gallery { } else if self.gallery {
@ -3862,6 +3871,7 @@ impl Tab {
} }
} }
Message::ItemLeft => { Message::ItemLeft => {
self.dehighlight_all();
if self.gallery { if self.gallery {
commands.append(&mut self.update(Message::GalleryPrevious, modifiers)); commands.append(&mut self.update(Message::GalleryPrevious, modifiers));
} else { } else {
@ -3920,6 +3930,7 @@ impl Tab {
} }
} }
Message::ItemRight => { Message::ItemRight => {
self.dehighlight_all();
if self.gallery { if self.gallery {
commands.append(&mut self.update(Message::GalleryNext, modifiers)); commands.append(&mut self.update(Message::GalleryNext, modifiers));
} else { } else {
@ -3961,6 +3972,7 @@ impl Tab {
} }
} }
Message::ItemUp => { Message::ItemUp => {
self.dehighlight_all();
if let Some(edit_location) = &mut self.edit_location { if let Some(edit_location) = &mut self.edit_location {
edit_location.select(false); edit_location.select(false);
} else if self.gallery { } else if self.gallery {