From c5a3bea6dfed1da693bc6263c36e0fa2bc9708f1 Mon Sep 17 00:00:00 2001 From: dshvaika Date: Wed, 16 Sep 2026 15:22:10 +0300 Subject: [PATCH] fix(iot-hub): let the keyboard reach every row of the search popup The popup keeps focus in the input and walks its rows with an active-descendant key manager, which only knows about options. A section header written as a span with role="button" and tabindex="0" is therefore unreachable: the arrow keys skip it, its keyup.enter can never fire because it can never hold focus, and Tab does not help since leaving the input closes the panel. That header is the only way from the popup into a type page, so without a mouse there was no way in at all. The footer had the same shape, though its action is also on the input's own Enter. The header also sat inside the group's label element, which is presentational, so the section's name came out as the header's whole text - "Devices +12 more" - wrapping a control nobody could operate. Header and footer are now options like every other row. They take part in arrow navigation, they read as part of the list, and the group wrapper goes away with the label it was distorting. Rows also acted on (click) alone. Pressing Enter on a highlighted result runs _selectViaInteraction, which is not a DOM click, so the card never opened from the keyboard. Every row now acts on (onSelectionChange) guarded by isUserInput, one path for pointer and keyboard both. Enter in the field needed a guard to go with that: the trigger acts on keydown and this handler runs on keyup, which the trigger's preventDefault does not stop, so one Enter would have opened a result and then navigated away from it. --- .../pages/iot-hub/iot-hub-home.component.html | 76 +++++++++---------- .../pages/iot-hub/iot-hub-home.component.scss | 66 +++++++--------- .../pages/iot-hub/iot-hub-home.component.ts | 9 +++ 3 files changed, 75 insertions(+), 76 deletions(-) diff --git a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.html b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.html index c4d720976b..b2be21ac32 100644 --- a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.html +++ b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.html @@ -85,53 +85,51 @@ } @else { @for (group of searchResultGroups; track group.type) { - - - {{ getSearchGroupLabel(group.type) }} - @if (group.remaining > 0) { - - {{ 'iot-hub.section-more' | translate:{ count: group.remaining } }} - chevron_right - - } - - @for (item of group.items; track item.id) { - - @if (isCompactType(item.type)) { -
- {{ getCompactIcon(item) }} -
- } @else { -
- @if (getItemImage(item); as imgUrl) { - - } @else { - {{ getItemTypeIcon(item.type) }} - } -
- } -
- {{ item.name }} - - person - {{ item.creatorDisplayName }} - -
-
+ + {{ getSearchGroupLabel(group.type) }} + @if (group.remaining > 0) { + + {{ 'iot-hub.section-more' | translate:{ count: group.remaining } }} + chevron_right + } -
+ + @for (item of group.items; track item.id) { + + @if (isCompactType(item.type)) { +
+ {{ getCompactIcon(item) }} +
+ } @else { +
+ @if (getItemImage(item); as imgUrl) { + + } @else { + {{ getItemTypeIcon(item.type) }} + } +
+ } +
+ {{ item.name }} + + person + {{ item.creatorDisplayName }} + +
+
+ } } } - + diff --git a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.scss b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.scss index d8934e82ff..98b4ab0389 100644 --- a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.scss +++ b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.scss @@ -220,45 +220,32 @@ 0 114px 46px 0 rgba(0, 0, 0, 0.01), 0 178px 50px 0 rgba(0, 0, 0, 0); - // Section group — 12px gap between groups - .mat-mdc-optgroup + .mat-mdc-optgroup .mat-mdc-optgroup-label { + // Section header — an option like every other row, not a button beside them, so the arrow keys + // reach it and a screen reader reads it in the list. It IS the way into the type page: title + // left, how much is not shown plus a chevron right. There is deliberately no per-section + // "see all" row under the items; six of those on one panel is what this variant avoids. + // Design: 14px Medium, 0.25 tracking, black-tertiary, 4px V / 16px H, 12px above each section. + .mat-mdc-option.tb-search-popup-group-header { + padding: 4px 16px; + min-height: 28px; margin-top: 12px; + + &:first-child { + margin-top: 0; + } + + .mdc-list-item__primary-text { + justify-content: space-between; + } } - // Section title — Design: 14px Medium, 0.25 tracking, black-tertiary, 4px V / 16px H - .mat-mdc-optgroup .mat-mdc-optgroup-label { - padding: 4px 16px; - min-height: 28px; + .tb-search-popup-group-label { font-size: 14px; font-weight: 500; line-height: 20px; letter-spacing: 0.25px; color: rgba(0, 0, 0, 0.54); white-space: nowrap; - - .mdc-list-item__primary-text { - font-size: 14px; - font-weight: 500; - line-height: 20px; - letter-spacing: 0.25px; - color: rgba(0, 0, 0, 0.54); - // The header spans the panel so the count can sit against the right edge. Material's own - // label span is only as wide as its text. - width: 100%; - } - } - - // Section header — the label IS the link into the type page: title left, how much is not shown - // plus a chevron right. There is deliberately no per-section "see all" row under the items; - // six of those on one panel is what this variant was chosen to avoid. - .tb-search-popup-group-header { - display: flex; - align-items: center; - justify-content: space-between; - gap: 16px; - width: 100%; - cursor: pointer; - outline: none; } .tb-search-popup-group-more { @@ -281,7 +268,7 @@ } // Item row — Design: 8px V / 16px H, 16px gap, centered - .mat-mdc-optgroup .mat-mdc-option:not(.mat-mdc-option-multiple) { + .mat-mdc-option:not(.mat-mdc-option-multiple) { padding: 8px 16px; min-height: auto; height: auto; @@ -426,26 +413,31 @@ } // Footer — Design: 40px h, 8px V / 16px H, 1px top border, tb-primary text - .tb-search-popup-footer { + .mat-mdc-option.tb-search-popup-footer { position: sticky; bottom: 0; + z-index: 1; border-top: 1px solid rgba(0, 0, 0, 0.12); height: 40px; min-height: 40px; padding: 8px 16px; - display: flex; - align-items: center; - justify-content: flex-start; font-size: 14px; font-weight: 500; line-height: 20px; letter-spacing: 0.25px; color: $tb-primary-color; - cursor: pointer; background: white; white-space: nowrap; - &:hover { + .mdc-list-item__primary-text { + justify-content: flex-start; + font: inherit; + letter-spacing: inherit; + color: inherit; + } + + &:hover:not(.mdc-list-item--disabled), + &.mat-mdc-option-active:not(.mdc-list-item--disabled) { background: #f5f5f5; } } diff --git a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.ts b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.ts index 91511f533d..8e6038ef96 100644 --- a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.ts +++ b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.ts @@ -239,7 +239,16 @@ export class TbIotHubHomeComponent implements OnInit, OnDestroy { setTimeout(() => this.searchAutoTrigger?.openPanel()); } + /** + * Enter in the field opens the search page - unless the panel has an option highlighted, which + * the trigger has already acted on during keydown. This runs on keyup, which preventDefault on + * the keydown does not stop, so without the guard one Enter would both open a result and + * navigate away from it. + */ onSearch(): void { + if (this.searchAutoTrigger?.activeOption) { + return; + } this.seeAllResults(); }