fix: request redraw when menu item hover state changes

This commit is contained in:
Hojjat 2026-08-10 12:12:18 -06:00 • committed by Michael Murphy
parent 633e6ab83f
commit 5da2e94337
2 changed files with 15 additions and 13 deletions

View file

@ -366,7 +366,8 @@ where
let mut current_offset = 0.0;
let previous_hover_option = self.hovered_option.take();
let previous_hover_option = self.hovered_option.clone();
*self.hovered_option = None;
for (element, elem_height) in self.options.elements().zip(heights) {
let bounds = Rectangle {
@ -377,27 +378,23 @@ where
};
if bounds.contains(cursor_position) {
*self.hovered_option = if let OptionElement::Option((_, item)) = element
{
if previous_hover_option.as_ref() == Some(item) {
previous_hover_option
} else {
shell.request_redraw();
if let OptionElement::Option((_, item)) = element {
*self.hovered_option = Some(item.clone());
if previous_hover_option.as_ref() != Some(item) {
if let Some(on_option_hovered) = self.on_option_hovered {
shell.publish(on_option_hovered(item.clone()));
}
Some(item.clone())
}
} else {
None
};
}
break;
}
current_offset += elem_height;
}
if *self.hovered_option != previous_hover_option {
shell.request_redraw();
}
}
}
Event::Touch(touch::Event::FingerPressed { .. }) => {

View file

@ -634,6 +634,10 @@ impl<'b, Message: Clone + 'static> Menu<'b, Message> {
shell,
);
if view_cursor.is_over(viewport) {
shell.request_redraw();
}
if self.is_overlay && view_cursor.is_over(viewport) {
shell.capture_event();
}
@ -1699,6 +1703,7 @@ fn process_scroll_events<Message>(
}
}
shell.capture_event();
shell.request_redraw();
});
}