@angular/cdk 18.2.0 → 18.2.2
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.
- package/a11y/index.d.ts +5 -1
- package/esm2022/a11y/key-manager/tree-key-manager-strategy.mjs +1 -1
- package/esm2022/a11y/key-manager/tree-key-manager.mjs +22 -12
- package/esm2022/drag-drop/drag-ref.mjs +3 -2
- package/esm2022/drag-drop/preview-ref.mjs +12 -4
- package/esm2022/tree/tree.mjs +23 -6
- package/esm2022/version.mjs +1 -1
- package/fesm2022/a11y.mjs +21 -11
- package/fesm2022/a11y.mjs.map +1 -1
- package/fesm2022/cdk.mjs +1 -1
- package/fesm2022/cdk.mjs.map +1 -1
- package/fesm2022/drag-drop.mjs +13 -4
- package/fesm2022/drag-drop.mjs.map +1 -1
- package/fesm2022/tree.mjs +26 -7
- package/fesm2022/tree.mjs.map +1 -1
- package/package.json +1 -1
- package/schematics/ng-add/index.js +1 -1
- package/schematics/ng-add/index.mjs +1 -1
- package/tree/index.d.ts +4 -1
package/fesm2022/a11y.mjs
CHANGED
|
@@ -737,21 +737,31 @@ class FocusKeyManager extends ListKeyManager {
|
|
|
737
737
|
* keyboard events occur.
|
|
738
738
|
*/
|
|
739
739
|
class TreeKeyManager {
|
|
740
|
-
|
|
741
|
-
if (this._hasInitialFocused) {
|
|
740
|
+
_initializeFocus() {
|
|
741
|
+
if (this._hasInitialFocused || this._items.length === 0) {
|
|
742
742
|
return;
|
|
743
743
|
}
|
|
744
|
-
|
|
745
|
-
return;
|
|
746
|
-
}
|
|
747
|
-
let focusIndex = 0;
|
|
744
|
+
let activeIndex = 0;
|
|
748
745
|
for (let i = 0; i < this._items.length; i++) {
|
|
749
746
|
if (!this._skipPredicateFn(this._items[i]) && !this._isItemDisabled(this._items[i])) {
|
|
750
|
-
|
|
747
|
+
activeIndex = i;
|
|
751
748
|
break;
|
|
752
749
|
}
|
|
753
750
|
}
|
|
754
|
-
this.
|
|
751
|
+
const activeItem = this._items[activeIndex];
|
|
752
|
+
// Use `makeFocusable` here, because we want the item to just be focusable, not actually
|
|
753
|
+
// capture the focus since the user isn't interacting with it. See #29628.
|
|
754
|
+
if (activeItem.makeFocusable) {
|
|
755
|
+
this._activeItem?.unfocus();
|
|
756
|
+
this._activeItemIndex = activeIndex;
|
|
757
|
+
this._activeItem = activeItem;
|
|
758
|
+
this._typeahead?.setCurrentSelectedItemIndex(activeIndex);
|
|
759
|
+
activeItem.makeFocusable();
|
|
760
|
+
}
|
|
761
|
+
else {
|
|
762
|
+
// Backwards compatibility for items that don't implement `makeFocusable`.
|
|
763
|
+
this.focusItem(activeIndex);
|
|
764
|
+
}
|
|
755
765
|
this._hasInitialFocused = true;
|
|
756
766
|
}
|
|
757
767
|
/**
|
|
@@ -800,7 +810,7 @@ class TreeKeyManager {
|
|
|
800
810
|
this._items = newItems.toArray();
|
|
801
811
|
this._typeahead?.setItems(this._items);
|
|
802
812
|
this._updateActiveItemIndex(this._items);
|
|
803
|
-
this.
|
|
813
|
+
this._initializeFocus();
|
|
804
814
|
});
|
|
805
815
|
}
|
|
806
816
|
else if (isObservable(items)) {
|
|
@@ -808,12 +818,12 @@ class TreeKeyManager {
|
|
|
808
818
|
this._items = newItems;
|
|
809
819
|
this._typeahead?.setItems(newItems);
|
|
810
820
|
this._updateActiveItemIndex(newItems);
|
|
811
|
-
this.
|
|
821
|
+
this._initializeFocus();
|
|
812
822
|
});
|
|
813
823
|
}
|
|
814
824
|
else {
|
|
815
825
|
this._items = items;
|
|
816
|
-
this.
|
|
826
|
+
this._initializeFocus();
|
|
817
827
|
}
|
|
818
828
|
if (typeof config.shouldActivationFollowFocus === 'boolean') {
|
|
819
829
|
this._shouldActivationFollowFocus = config.shouldActivationFollowFocus;
|