Skip to content

fix(material/chips): update chip-row disabled chip to be focused #30364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions src/dev-app/chips/chips-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,74 @@ <h4>Options</h4>
</mat-card-content>
</mat-card>

<mat-card>
<mat-toolbar color="primary">Disabled Input Chips</mat-toolbar>

<mat-card-content>
<p>
The <code>&lt;mat-chip-grid&gt;</code> component pairs with the <code>matChipInputFor</code> directive
to convert user input text into chips.
They can be used inside a <code>&lt;mat-form-field&gt;</code>.
</p>

<h4>Input is last child of chip grid</h4>

<mat-form-field class="demo-has-chip-list">
<mat-label>New Contributor...</mat-label>
<mat-chip-grid #chipGrid1 [(ngModel)]="selectedPeople" required>
@for (person of people; track person) {
<mat-chip-row
[disabled]="true"
[editable]="editable"
(removed)="remove(person)"
(edited)="edit(person, $event)">
{{person.name}}
<button matChipRemove aria-label="Remove contributor">
<mat-icon>close</mat-icon>
</button>
</mat-chip-row>
}
<input
[matChipInputFor]="chipGrid1"
[matChipInputSeparatorKeyCodes]="separatorKeysCodes"
[matChipInputAddOnBlur]="addOnBlur"
(matChipInputTokenEnd)="add($event)" />
</mat-chip-grid>
</mat-form-field>

<h4>Input is next sibling child of chip grid</h4>

<mat-form-field>
<mat-label>New Contributor...</mat-label>
<mat-chip-grid #chipGrid2 [(ngModel)]="selectedPeople" required>
@for (person of people; track person) {
<mat-chip-row disabled (removed)="remove(person)">
{{person.name}}
<button matChipRemove aria-label="Remove contributor">
<mat-icon>close</mat-icon>
</button>
</mat-chip-row>
}
</mat-chip-grid>
<input [matChipInputFor]="chipGrid2"
[matChipInputSeparatorKeyCodes]="separatorKeysCodes"
[matChipInputAddOnBlur]="addOnBlur"
(matChipInputTokenEnd)="add($event)" />
</mat-form-field>

<p>
The example above has overridden the <code>[separatorKeys]</code> input to allow for
<code>ENTER</code>, <code>COMMA</code> and <code>SEMICOLON</code> keys.
</p>

<h4>Options</h4>
<p>
<mat-checkbox name="addOnBlur" [(ngModel)]="addOnBlur">Add on Blur</mat-checkbox>
</p>

</mat-card-content>
</mat-card>

<mat-card>
<mat-toolbar color="primary">Miscellaneous</mat-toolbar>
<mat-card-content>
Expand Down
2 changes: 1 addition & 1 deletion src/material/chips/chip-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class MatChipRow extends MatChip implements AfterViewInit {

/** Sends focus to the first gridcell when the user clicks anywhere inside the chip. */
_handleFocus() {
if (!this._isEditing && !this.disabled) {
if (!this._isEditing) {
this.focus();
}
}
Expand Down
Loading