diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/_iot-hub-common.scss b/ui-ngx/src/app/modules/home/components/iot-hub/_iot-hub-common.scss index d247f20112..96697ebe74 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/_iot-hub-common.scss +++ b/ui-ngx/src/app/modules/home/components/iot-hub/_iot-hub-common.scss @@ -119,3 +119,39 @@ pointer-events: none; } } + +// Scroll area that shows its thumb only while the container is hovered — the filter panels' +// own treatment, kept here so the two that use it cannot drift apart. +// +// Not the app-wide one: theme.scss keeps its thumb permanently visible. Whether these panels +// should do the same, and whether to add the standardised scrollbar-width / scrollbar-color +// that Firefox reads, is a question for the IoT Hub filter UI as a whole rather than for one +// panel; iot-hub-browse and dashboard-widget-select carry copies of this same treatment. +@mixin tb-iot-hub-hover-scrollbar { + &::-webkit-scrollbar { + width: 6px; + } + + &::-webkit-scrollbar-track { + background-color: transparent; + } + + &::-webkit-scrollbar-thumb { + background-color: transparent; + border-radius: 3px; + } + + &:hover { + &::-webkit-scrollbar-track { + background-color: rgba(0, 0, 0, 0.04); + } + + &::-webkit-scrollbar-thumb { + background-color: rgba(0, 0, 0, 0.2); + + &:hover { + background-color: rgba(0, 0, 0, 0.35); + } + } + } +} diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-facet-list.component.scss b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-facet-list.component.scss index e5fc43f803..4df80a68e1 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-facet-list.component.scss +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-facet-list.component.scss @@ -45,32 +45,7 @@ overflow-y: auto; } - &::-webkit-scrollbar { - width: 6px; - } - - &::-webkit-scrollbar-track { - background-color: transparent; - } - - &::-webkit-scrollbar-thumb { - background-color: transparent; - border-radius: 3px; - } - - &:hover { - &::-webkit-scrollbar-track { - background-color: rgba(0, 0, 0, 0.04); - } - - &::-webkit-scrollbar-thumb { - background-color: rgba(0, 0, 0, 0.2); - - &:hover { - background-color: rgba(0, 0, 0, 0.35); - } - } - } + @include tb-iot-hub-hover-scrollbar; } .tb-iot-hub-facet-search { diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-search.component.scss b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-search.component.scss index 32c7a51458..3f946404ad 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-search.component.scss +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-search.component.scss @@ -221,32 +221,7 @@ overflow-y: auto; padding-top: 20px; - &::-webkit-scrollbar { - width: 6px; - } - - &::-webkit-scrollbar-track { - background-color: transparent; - } - - &::-webkit-scrollbar-thumb { - background-color: transparent; - border-radius: 3px; - } - - &:hover { - &::-webkit-scrollbar-track { - background-color: rgba(0, 0, 0, 0.04); - } - - &::-webkit-scrollbar-thumb { - background-color: rgba(0, 0, 0, 0.2); - - &:hover { - background-color: rgba(0, 0, 0, 0.35); - } - } - } + @include tb-iot-hub-hover-scrollbar; } // The close button and heading belong to the narrow layout only. 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 b2be21ac32..564f89ca46 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 @@ -86,7 +86,7 @@ } @else { @for (group of searchResultGroups; track group.type) { + (onSelectionChange)="rowSelectedByUser($event) && navigateToSection(group.type)"> {{ getSearchGroupLabel(group.type) }} @if (group.remaining > 0) { @@ -96,8 +96,8 @@ } @for (item of group.items; track item.id) { - + @if (isCompactType(item.type)) {
{{ getCompactIcon(item) }} @@ -123,7 +123,7 @@ } } + (onSelectionChange)="rowSelectedByUser($event) && seeAllResults()"> @if (searchText?.trim(); as query) { {{ 'iot-hub.see-results-for' | translate:{ search: query } }} } @else { 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 98b4ab0389..8a89ebae44 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,6 +220,27 @@ 0 114px 46px 0 rgba(0, 0, 0, 0.01), 0 178px 50px 0 rgba(0, 0, 0, 0); + // Every row of the panel shares the flex line and the highlight; the boxes differ per kind + // below. Each kind is selected by its own class rather than by leaning on source order, since + // .mat-mdc-option. and .mat-mdc-option:not(...) tie on specificity. + .mat-mdc-option { + .mdc-list-item__primary-text { + display: flex; + align-items: center; + gap: 16px; + width: 100%; + } + + &:hover:not(.mdc-list-item--disabled), + &.mat-mdc-option-active:not(.mdc-list-item--disabled) { + background: rgba(0, 0, 0, 0.04); + } + + .mat-icon, tb-icon { + margin-right: 0; + } + } + // 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 @@ -268,26 +289,10 @@ } // Item row — Design: 8px V / 16px H, 16px gap, centered - .mat-mdc-option:not(.mat-mdc-option-multiple) { + .mat-mdc-option.tb-search-popup-item { padding: 8px 16px; min-height: auto; height: auto; - - &:hover:not(.mdc-list-item--disabled), - &.mat-mdc-option-active:not(.mdc-list-item--disabled) { - background: rgba(0, 0, 0, 0.04); - } - - .mat-icon, tb-icon { - margin-right: 0; - } - - .mdc-list-item__primary-text { - display: flex; - align-items: center; - gap: 16px; - width: 100%; - } } // Thumbnail — Design: 99px x 56px, 4px radius, 1px border, 4% bg @@ -392,6 +397,7 @@ .tb-search-popup-no-results { pointer-events: none; opacity: 1 !important; + padding: 8px 16px; } .tb-search-popup-no-results-content { 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 8e6038ef96..4efb672e33 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 @@ -3,6 +3,7 @@ import { Component, OnInit, OnDestroy, ViewChild, ElementRef } from '@angular/core'; import { Router } from '@angular/router'; import { MatAutocompleteTrigger } from '@angular/material/autocomplete'; +import { MatOptionSelectionChange } from '@angular/material/core'; import { BreakpointObserver } from '@angular/cdk/layout'; import { forkJoin, of, Subject, Subscription } from 'rxjs'; import { catchError, debounceTime, distinctUntilChanged, switchMap } from 'rxjs/operators'; @@ -66,6 +67,7 @@ export class TbIotHubHomeComponent implements OnInit, OnDestroy { searchLoading = false; @ViewChild(MatAutocompleteTrigger) searchAutoTrigger: MatAutocompleteTrigger; @ViewChild('searchInput', {read: ElementRef}) searchInputRef: ElementRef; + private enterHandledByRow = false; private searchSubject = new Subject(); private searchSubscription: Subscription; @@ -217,6 +219,7 @@ export class TbIotHubHomeComponent implements OnInit, OnDestroy { } onSearchInput(): void { + this.enterHandledByRow = false; this.searchLoading = true; this.searchSubject.next(this.searchText || ''); } @@ -240,13 +243,31 @@ export class TbIotHubHomeComponent implements OnInit, OnDestroy { } /** - * 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. + * Gate on every row's selection: false for the panel's own bookkeeping, true when the user + * picked the row - and then it records that this keystroke has been dealt with. + * + * One Enter reaches two handlers. The autocomplete trigger acts on keydown, the field's own + * handler on keyup, and preventDefault on the first does not stop the second. The trigger's + * activeOption cannot tell them apart either: it clears it inside that same keydown, so by + * keyup it reads empty whether or not a row acted. The row that acted says so instead, which + * does not depend on the order the two handlers run in. + */ + rowSelectedByUser(event: MatOptionSelectionChange): boolean { + if (!event.isUserInput) { + return false; + } + this.enterHandledByRow = true; + return true; + } + + /** + * Enter in the field opens the search page, unless a row has just acted on this same press. + * The flag is also cleared on input, since a pointer selection sets it with no keyup to follow + * and would otherwise swallow the next Enter. */ onSearch(): void { - if (this.searchAutoTrigger?.activeOption) { + if (this.enterHandledByRow) { + this.enterHandledByRow = false; return; } this.seeAllResults();