Fix focus cycle on dialogs without buttons
@@ -286,7 +286,8 @@ impl Dialog {
match self.content.on_event(
event.relativized((self.padding + self.borders).top_left()),
) {
- EventResult::Ignored if !self.buttons.is_empty() => {
+ EventResult::Ignored => {
+ if !self.buttons.is_empty() {
match event {
Event::Key(Key::Down)
| Event::Key(Key::Tab)
@@ -297,6 +298,27 @@ impl Dialog {
}
_ => EventResult::Ignored,
}
+ } else {
+ match event {
+ Event::Shift(Key::Tab) => {
+ if self.content.take_focus(Direction::back()) {
+ self.focus = DialogFocus::Content;
+ EventResult::Consumed(None)
+ } else {
+ EventResult::Ignored
+ }
+ }
+ Event::Key(Key::Tab) => {
+ if self.content.take_focus(Direction::front()) {
+ self.focus = DialogFocus::Content;
+ EventResult::Consumed(None)
+ } else {
+ EventResult::Ignored
+ }
+ }
+ _ => EventResult::Ignored,
+ }
+ }
}
res => res,
}
