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

fix(form-field): outline gap not calculated in shadow dom #17303

Merged
merged 1 commit into from
Oct 11, 2019

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Oct 6, 2019

Currently we check whether the form field is inside the DOM using documentElement.contains(formField) so that we don't try to calculate the outline gap. The problem is that contains won't catch elements inside the shadow DOM. These changes rework the check to use getRootNode instead.

Fixes #17262.

Currently we check whether the form field is inside the DOM using `documentElement.contains(formField)` so that we don't try to calculate the outline gap. The problem is that `contains` won't catch elements inside the shadow DOM. These changes rework the check to use `getRootNode` instead.

Fixes angular#17262.
@crisbeto crisbeto added 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 labels Oct 6, 2019
@crisbeto crisbeto requested a review from mmalerba as a code owner October 6, 2019 08:35
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Oct 6, 2019
@crisbeto crisbeto changed the title fix(form-field): outline gap no calculated in shadow dom fix(form-field): outline gap not calculated in shadow dom Oct 6, 2019
@@ -582,4 +582,20 @@ export class MatFormField extends _MatFormFieldMixinBase
private _getStartEnd(rect: ClientRect): number {
return this._previousDirection === 'rtl' ? rect.right : rect.left;
}

/** Checks whether the form field is attached to the DOM. */
private _isAttachedToDOM(): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we currently use a similar pattern elsewhere in the library? If so might make sense to put as a utility in cdk or material/core

Copy link
Member Author

Choose a reason for hiding this comment

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

I did a quick a search and it doesn't look like we do.

@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label Oct 8, 2019
@jelbourn jelbourn merged commit 1b94295 into angular:master Oct 11, 2019
@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 Nov 11, 2019
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 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.

mat-form-field does not display outline label properly in ShadowDom
4 participants