Skip to content

bug(chips): fixes placeholder in chip inputs #7481 #7509

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 4 commits into from
Oct 12, 2017
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
4 changes: 2 additions & 2 deletions src/lib/chips/chip-list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,9 @@ describe('MatChipList', () => {

});

it('should not float placeholder if no chip is selected', () => {
it('should float placeholder if chip is selected', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this was testing when there's a chip present but not selected, so it should still be "... if no chip is selected".

@tinayuangao Why was this expected to be not floating in the first place? It seems like we would want it to float even if the chip isn't selected, to avoid overlap.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test was invalid, it was expecting the inverse logic that was the bug before.

Copy link
Contributor

Choose a reason for hiding this comment

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

agreed, but it was the "not float" part that was invalid not the "no chip is selected" part

expect(formField.classList.contains('mat-form-field-should-float'))
.toBe(false, 'placeholder should not be floating');
.toBe(true, 'placeholder should be floating');
});

it('should remove selection if chip has been removed', async(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/chips/chip-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export class MatChipList implements MatFormFieldControl<any>, ControlValueAccess
}

get shouldPlaceholderFloat(): boolean {
return this.empty;
return !this.empty || this.focused;
}

/** Whether this chip-list is disabled. */
Expand Down