Skip to content

Commit 4713848

Browse files
committed
add comment
1 parent 82506e0 commit 4713848

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/material/chips/chip-row.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,17 @@ export class MatChipRow extends MatChip implements AfterViewInit {
9393
/** The projected chip edit input. */
9494
@ContentChild(MatChipEditInput) contentEditInput?: MatChipEditInput;
9595

96-
_isEditing = false;
96+
/**
97+
* Set with a timeout when the chips has been focused via mouse or keyboard.
98+
*
99+
* This allows us to ensure chip is already focused when deciding whether to enter the
100+
* edit mode on a subsequent click. Otherwise, the chip appears focused when handling the
101+
* first click event.
102+
*/
97103
_alreadyFocused = false;
98104

105+
_isEditing = false;
106+
99107
constructor(...args: unknown[]);
100108

101109
constructor() {
@@ -110,6 +118,7 @@ export class MatChipRow extends MatChip implements AfterViewInit {
110118
});
111119
this._onFocus.pipe(takeUntil(this.destroyed)).subscribe(() => {
112120
if (!this._isEditing && !this.disabled) {
121+
// Need a timeout to ensure flag not set while handling the first click.
113122
this._ngZone.runOutsideAngular(() => {
114123
setTimeout(() => (this._alreadyFocused = true), 100);
115124
});

0 commit comments

Comments
 (0)