Skip to content

Commit 8ede209

Browse files
committed
ui/ncurses: Properly set focus when updating subset
When a subset widget is made empty focus is switched to the first visible field. It should actually be set to the first visible and active field, otherwise we can try to focus an un-selectable label. While we're here, also properly set the visibility for the autoboot enable/disable widget. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
1 parent 96f9b8c commit 8ede209

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

ui/ncurses/nc-config.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ static void config_screen_layout_widgets(struct config_screen *screen)
411411
widget_move(wl, y, screen->label_x);
412412

413413
wf = widget_select_base(screen->widgets.autoboot_f);
414+
widget_set_visible(wf, true);
414415
widget_move(wf, y, screen->field_x);
415416
y += widget_height(wf);
416417

ui/ncurses/nc-widgets.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ static void subset_delete_active(struct nc_widget_subset *subset, int idx)
466466
struct nc_widget *widget;
467467
size_t rem;
468468
int i, val;
469+
uint32_t opts;
469470

470471
/* Shift field focus to nearest active option or next visible field */
471472
if (subset->n_active > 1) {
@@ -477,8 +478,11 @@ static void subset_delete_active(struct nc_widget_subset *subset, int idx)
477478
} else {
478479
for (i = 0; i < set->n_fields; i++)
479480
if (field_visible(set->fields[i])) {
480-
set->cur_field = set->fields[i];
481-
break;
481+
opts = field_opts(set->fields[i]);
482+
if ((opts & O_ACTIVE) == O_ACTIVE) {
483+
set->cur_field = set->fields[i];
484+
break;
485+
}
482486
}
483487
}
484488

0 commit comments

Comments
 (0)