Skip to content

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

Merged
jelbourn merged 1 commit into
angular:masterfrom
asyncliz:floating-label-required
May 8, 2020
Merged

jelbourn merged 1 commit into
angular:masterfrom
asyncliz:floating-label-required

Conversation

@asyncliz

@asyncliz asyncliz commented May 7, 2020

Copy link
Copy Markdown
Contributor

No description provided.

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

@jelbourn jelbourn left a comment

Copy link
Copy Markdown
Contributor

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

jelbourn commented May 7, 2020

Copy link
Copy Markdown
Contributor

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

@asyncliz

asyncliz commented May 7, 2020

Copy link
Copy Markdown
Contributor Author

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

crisbeto commented May 8, 2020

Copy link
Copy Markdown
Member

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

asyncliz commented May 8, 2020

Copy link
Copy Markdown
Contributor Author

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 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown

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

5 participants