Skip to content
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

Chips placeholder bound to variable only shows after triggering its change detection (by clicking component). #11861

Closed
ghost opened this issue Jun 20, 2018 · 1 comment · Fixed by #12422
Assignees
Labels
P4 A relatively minor issue that is not relevant to core functions

Comments

@ghost
Copy link

ghost commented Jun 20, 2018

Bug, feature request, or proposal:

Bug

What is the expected behavior?

If you have a chips component roughly like the following (check stackblitz for a working example). The placeholder will not render as expected (hide on disabled true; show on disabled false) until you somehow trigger change detection by clicking the component.

<mat-form-field >
  <mat-chip-list #chipList>
    <mat-chip></mat-chip>
    <input [placeholder]="getPlaceholder()">
  </mat-chip-list>
</mat-form-field>
@Component({
  selector: 'chips',
  templateUrl: 'chips.html',
})
export class ChipsInputExample {

  @Input() disabled: boolean;

  getPlaceholder(): string {
    return this.disabled ? '' : 'Has lime';    
  };
}

What is the current behavior?

Only shows placeholder (for disabled === false) after user triggers change detection.

What are the steps to reproduce?

https://stackblitz.com/edit/angular-hxrcpk

Other similar example:
https://stackblitz.com/edit/angular-hxrcpk-3zsauz

What is the use-case or motivation for changing an existing behavior?

Showing/hiding placeholder based on component's disabled input parameter.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Angular: 6.0.5
Material 6.0.3

Is there anything else we should know?

This is not a new behaviour, it already happened in past material major versions.

crisbeto added a commit to crisbeto/material2 that referenced this issue Jul 28, 2018
…ed to form field

Fixes changes to the placeholder of a chip input not being propagated to its parent form field. Also un-deprecates the input for `placeholder`, because we need to know when it has changed.

Fixes angular#11861.
@crisbeto crisbeto assigned crisbeto and unassigned tinayuangao Jul 28, 2018
@crisbeto crisbeto added has pr P4 A relatively minor issue that is not relevant to core functions labels Jul 28, 2018
crisbeto added a commit to crisbeto/material2 that referenced this issue Jul 30, 2018
…ed to form field

Fixes changes to the placeholder of a chip input not being propagated to its parent form field. Also un-deprecates the input for `placeholder`, because we need to know when it has changed.

Fixes angular#11861.
jelbourn pushed a commit that referenced this issue Aug 1, 2018
…ed to form field (#12422)

Fixes changes to the placeholder of a chip input not being propagated to its parent form field. Also un-deprecates the input for `placeholder`, because we need to know when it has changed.

Fixes #11861.
jelbourn pushed a commit that referenced this issue Aug 7, 2018
…ed to form field (#12422)

Fixes changes to the placeholder of a chip input not being propagated to its parent form field. Also un-deprecates the input for `placeholder`, because we need to know when it has changed.

Fixes #11861.
jelbourn pushed a commit that referenced this issue Aug 7, 2018
…ed to form field (#12422)

Fixes changes to the placeholder of a chip input not being propagated to its parent form field. Also un-deprecates the input for `placeholder`, because we need to know when it has changed.

Fixes #11861.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jun 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P4 A relatively minor issue that is not relevant to core functions
Projects
None yet
2 participants