Skip to content

fix(material-experimental/mdc-form-field): make sure fonts are loaded… #21245

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
Dec 11, 2020

Conversation

annieyw
Copy link
Contributor

@annieyw annieyw commented Dec 7, 2020

… before calculating notch width

The label width was being calculated before the fonts were loaded which caused the label to be cut off sometimes. By calculating the width after fonts.ready resolves we can be sure that the label will be the correct size.
Note that the workaround for IE is not perfect as depending on the connection speed the font still might not be loaded after the time out.

Before:
9qHkqooP5ytmq42

After:
5XkdAvbCDJpEwM6

@annieyw annieyw added P2 The issue is important to a large percentage of users, with a workaround G This is is related to a Google internal issue target: patch This PR is targeted for the next patch release labels Dec 7, 2020
@annieyw annieyw requested review from jelbourn and mmalerba December 7, 2020 23:21
@annieyw annieyw requested a review from devversion as a code owner December 7, 2020 23:21
@google-cla google-cla bot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Dec 7, 2020
@annieyw
Copy link
Contributor Author

annieyw commented Dec 8, 2020

  • use DOCUMENT injection token
  • use feature detection instead of checking for browser

Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

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

LGTM

@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label Dec 8, 2020
@annieyw
Copy link
Contributor Author

annieyw commented Dec 8, 2020

Add markForCheck because original change was causing prefilled form fields to have a large gap. Waiting for the fonts to the loaded causes a delay so extra change detection is needed to reflect the calculated width
6PamohuFcy4JD7k

@annieyw
Copy link
Contributor Author

annieyw commented Dec 10, 2020

Some tweaks to make sure this change works in async tests as zone.js doesn't patch the FontFaceSet API and to account for really slow connections.

@wagnermaciel wagnermaciel merged commit 87dcfad into angular:master Dec 11, 2020
wagnermaciel pushed a commit that referenced this pull request Dec 11, 2020
… before calculating notch width (#21245)

(cherry picked from commit 87dcfad)
@annieyw annieyw deleted the notch-width branch December 29, 2020 06:54
wagnermaciel pushed a commit to wagnermaciel/components that referenced this pull request Jan 14, 2021
@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 Jan 29, 2021
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 G This is is related to a Google internal issue P2 The issue is important to a large percentage of users, with a workaround target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants