Skip to content

fix(chips): unable to bind to chip input placeholder #10855

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

Merged
merged 1 commit into from
Apr 26, 2018
Merged
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
14 changes: 12 additions & 2 deletions src/lib/chips/chip-input.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ describe('MatChipInput', () => {
let inputDebugElement: DebugElement;
let inputNativeElement: HTMLElement;
let chipInputDirective: MatChipInput;

let dir = 'ltr';

beforeEach(async(() => {
Expand Down Expand Up @@ -56,6 +55,15 @@ describe('MatChipInput', () => {
it('should have a default id', () => {
expect(inputNativeElement.getAttribute('id')).toBeTruthy();
});

it('should allow binding to the `placeholder` input', () => {
expect(inputNativeElement.hasAttribute('placeholder')).toBe(false);

testChipInput.placeholder = 'bound placeholder';
fixture.detectChanges();

expect(inputNativeElement.getAttribute('placeholder')).toBe('bound placeholder');
});
});

describe('[addOnBlur]', () => {
Expand Down Expand Up @@ -142,11 +150,13 @@ describe('MatChipInput', () => {
</mat-chip-list>
<input matInput [matChipInputFor]="chipList"
[matChipInputAddOnBlur]="addOnBlur"
(matChipInputTokenEnd)="add($event)" />
(matChipInputTokenEnd)="add($event)"
[placeholder]="placeholder" />
`
})
class TestChipInput {
addOnBlur: boolean = false;
placeholder = '';

add(_: MatChipInputEvent) {
}
Expand Down
7 changes: 6 additions & 1 deletion src/lib/chips/chip-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ let nextUniqueId = 0;
'(focus)': '_focus()',
'(input)': '_onInput()',
'[id]': 'id',
'[attr.placeholder]': 'placeholder || null',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tinayuangao should we deprecate the placeholder input for 7.0? It doesn't do anything, apart from proxying the value to the placeholder attribute. Consumers can achieve the same by binding to attr.placeholder.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think we can

}
})
export class MatChipInput {
Expand Down Expand Up @@ -75,7 +76,11 @@ export class MatChipInput {
@Output('matChipInputTokenEnd')
chipEnd: EventEmitter<MatChipInputEvent> = new EventEmitter<MatChipInputEvent>();

/** The input's placeholder text. */
/**
* The input's placeholder text.
* @deprecated Bind to the `placeholder` attribute directly.
* @deletion-target 7.0.0
*/
@Input() placeholder: string = '';

/** Unique id for the input. */
Expand Down