@truenas/ui-components 0.4.9 → 0.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -9584,21 +9584,20 @@ class TnSelectComponent {
|
|
|
9584
9584
|
return;
|
|
9585
9585
|
}
|
|
9586
9586
|
this.isOpen.set(true);
|
|
9587
|
-
// Seed keyboard focus at the current selection when there is one
|
|
9588
|
-
//
|
|
9587
|
+
// Seed keyboard focus at the current selection when there is one, else at
|
|
9588
|
+
// the first navigable row. Something is ALWAYS highlighted while the panel
|
|
9589
|
+
// is open (matching mat-select): a freshly-opened select must be operable
|
|
9590
|
+
// with Enter/Space straight away, without an ArrowDown first.
|
|
9589
9591
|
const selected = this.selectedValue();
|
|
9590
|
-
|
|
9591
|
-
|
|
9592
|
-
this.
|
|
9593
|
-
|
|
9594
|
-
|
|
9595
|
-
|
|
9596
|
-
|
|
9597
|
-
|
|
9598
|
-
|
|
9599
|
-
else {
|
|
9600
|
-
this.focusedIndex.set(-1);
|
|
9601
|
-
}
|
|
9592
|
+
const idx = selected === null || selected === undefined
|
|
9593
|
+
? -1
|
|
9594
|
+
: this.navigableOptions().findIndex((x) => x.kind === 'option' && this.compareValues(x.option.value, selected));
|
|
9595
|
+
// findIndex can also miss (e.g. the selected option is disabled, so it
|
|
9596
|
+
// isn't navigable) — fall back to the first row there too. `-1` would
|
|
9597
|
+
// leave the panel with nothing highlighted, which is the state we're
|
|
9598
|
+
// avoiding. When `allowEmpty` is set the first row IS the empty option,
|
|
9599
|
+
// so a cleared value lands on it for free.
|
|
9600
|
+
this.focusedIndex.set(idx >= 0 ? idx : 0);
|
|
9602
9601
|
this.attachOverlay();
|
|
9603
9602
|
}
|
|
9604
9603
|
/**
|
|
@@ -9931,10 +9930,9 @@ class TnSelectComponent {
|
|
|
9931
9930
|
case 'ArrowDown':
|
|
9932
9931
|
event.preventDefault();
|
|
9933
9932
|
if (!this.isOpen()) {
|
|
9933
|
+
// openDropdown() already seeds the highlight (selection, else first),
|
|
9934
|
+
// so opening must not also advance a row.
|
|
9934
9935
|
this.openDropdown();
|
|
9935
|
-
if (this.focusedIndex() < 0) {
|
|
9936
|
-
this.moveFocus('first');
|
|
9937
|
-
}
|
|
9938
9936
|
}
|
|
9939
9937
|
else {
|
|
9940
9938
|
this.moveFocus(1);
|