@angular/cdk 18.2.9 → 18.2.11

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/fesm2022/tree.mjs CHANGED
@@ -2,7 +2,7 @@ import { SelectionModel, isDataSource } from '@angular/cdk/collections';
2
2
  import { isObservable, Subject, BehaviorSubject, of, combineLatest, EMPTY, concat } from 'rxjs';
3
3
  import { take, filter, takeUntil, startWith, tap, switchMap, map, reduce, concatMap, distinctUntilChanged } from 'rxjs/operators';
4
4
  import * as i0 from '@angular/core';
5
- import { InjectionToken, Directive, Inject, Optional, inject, Component, ViewEncapsulation, ChangeDetectionStrategy, Input, ViewChild, ContentChildren, EventEmitter, ChangeDetectorRef, booleanAttribute, Output, numberAttribute, NgModule } from '@angular/core';
5
+ import { InjectionToken, Directive, Inject, Optional, inject, ElementRef, Component, ViewEncapsulation, ChangeDetectionStrategy, Input, ViewChild, ContentChildren, EventEmitter, ChangeDetectorRef, booleanAttribute, Output, numberAttribute, NgModule } from '@angular/core';
6
6
  import { TREE_KEY_MANAGER } from '@angular/cdk/a11y';
7
7
  import * as i2 from '@angular/cdk/bidi';
8
8
  import { Directionality } from '@angular/cdk/bidi';
@@ -284,6 +284,7 @@ class CdkTree {
284
284
  constructor(_differs, _changeDetectorRef) {
285
285
  this._differs = _differs;
286
286
  this._changeDetectorRef = _changeDetectorRef;
287
+ this._elementRef = inject(ElementRef);
287
288
  this._dir = inject(Directionality);
288
289
  /** Subject that emits when the component has been destroyed. */
289
290
  this._onDestroy = new Subject();
@@ -845,7 +846,20 @@ class CdkTree {
845
846
  }
846
847
  /** `keydown` event handler; this just passes the event to the `TreeKeyManager`. */
847
848
  _sendKeydownToKeyManager(event) {
848
- this._keyManager.onKeydown(event);
849
+ // Only handle events directly on the tree or directly on one of the nodes, otherwise
850
+ // we risk interfering with events in the projected content (see #29828).
851
+ if (event.target === this._elementRef.nativeElement) {
852
+ this._keyManager.onKeydown(event);
853
+ }
854
+ else {
855
+ const nodes = this._nodes.getValue();
856
+ for (const [, node] of nodes) {
857
+ if (event.target === node._elementRef.nativeElement) {
858
+ this._keyManager.onKeydown(event);
859
+ break;
860
+ }
861
+ }
862
+ }
849
863
  }
850
864
  /** Gets all nested descendants of a given node. */
851
865
  _getDescendants(dataNode) {