Skip to content

fix(material-experimental/form-field): add setLabelRequired adapter #19284

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
May 8, 2020

Conversation

asyncLiz
Copy link
Contributor

@asyncLiz asyncLiz commented May 7, 2020

No description provided.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label May 7, 2020
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

Feel free to ping me when the corresponding change lands in Google so I can merge this.

@jelbourn
Copy link
Member

jelbourn commented May 7, 2020

Actually it looks like CI is failing here- is there a new MDC version necessary with the change?

@asyncLiz
Copy link
Contributor Author

asyncLiz commented May 7, 2020

Yes. Once the CL is submitted, we'll need to update this PR with the updated canary build

@jelbourn jelbourn added blocked This issue is blocked by some external factor, such as a prerequisite PR lgtm P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent labels May 7, 2020
@crisbeto
Copy link
Member

crisbeto commented May 8, 2020

Looks like the MDC change made it into a Canary build and got picked up by the cronjob. https://circleci.com/gh/angular/components/139322

@asyncLiz
Copy link
Contributor Author

asyncLiz commented May 8, 2020

Working on updating this now!

@asyncLiz asyncLiz force-pushed the floating-label-required branch from 983745d to cb5b949 Compare May 8, 2020 19:09
@asyncLiz asyncLiz requested a review from a team as a code owner May 8, 2020 19:09

// TODO: MDC now supports setting the required asterisk marker directly on
// the label component. This adapter method may be implemented and
// mat-mdc-form-field-required-marker removed.
Copy link
Member

Choose a reason for hiding this comment

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

Is the plan that we clean this up as a follow-up? I don't think we'll use that given that we support custom form field controls and/or their associated ng control.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's optional to clean up.

I didn't do a deep dive into the component, but it looks like the <span class="mat-mdc-form-field-required-marker"> accomplishes the same goal.

Instead of doing it in markup, you could do it in this method:

setLabelRequired(isRequired: boolean) {
  if (!this.hideRequiredMarker && this._control.required && !this.control.disabled) {
    // toggles the `mdc-floating-label--required` class
    this._floatingLabel.required = isRequired;
  }
}

Definitely a lot of opinions and unknowns on my part. Feel free to update the comment and either implement something, or leave it as no-op.

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense. I don't think we'll be able to rely on that method since we want to update whenever the input is refreshed, so we rely on change detection. Doing that manually might be overly complicated

@devversion devversion added action: merge The PR is ready for merge by the caretaker and removed blocked This issue is blocked by some external factor, such as a prerequisite PR labels May 8, 2020
@jelbourn jelbourn added the target: patch This PR is targeted for the next patch release label May 8, 2020
@jelbourn jelbourn merged commit 7b42c7e into angular:master May 8, 2020
@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 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants