-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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): update label gap for outline style within the ngZone #12555
Conversation
bfab50d
to
1ffd52f
Compare
4609d33
to
3f84826
Compare
src/lib/form-field/form-field.ts
Outdated
|
||
/** | ||
* @deprecated | ||
* @breaking-change 7.0.0 | ||
*/ | ||
@ViewChild('underline') underlineRef: ElementRef; | ||
|
||
@ViewChild('connectionContainer') _connectionContainerRef: ElementRef; | ||
@ViewChild('connectionContainer') _connectionContainerRef: ElementRef<HTMLDivElement>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: just HTMLElement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the connectionContainer
attribute is on a div
we can be sure that it will be ElementRef<HTMLDivElement>
, we should be exact correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're not using any methods/properties specific to a div and I should be able to change the div to a span, or some other element without needing to change the logic. So to me that indicates that we should only require it to be an HTMLElement
src/lib/form-field/form-field.ts
Outdated
Promise.resolve().then(() => this.updateOutlineGap()); | ||
} | ||
} | ||
this.updateOutlineGap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want that initialGapCalculated
check so that we don't wind up measuring elements on every change detection
src/lib/form-field/form-field.ts
Outdated
let startWidth = 0; | ||
let gapWidth = 0; | ||
const startEls = this._connectionContainerRef.nativeElement.querySelectorAll<HTMLDivElement>( | ||
'.mat-form-field-outline > .mat-form-field-outline-start'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a selector this complex? why not just .mat-form-field-outline-start
?
de51165
to
1871760
Compare
src/lib/form-field/form-field.ts
Outdated
// outline elements to show in the dom. This is a safe action to take because | ||
// updateOutlineGap does not cause a change detection cycle to run. setTimeout is used | ||
// because the update needs to be in a a new task rather than the next microtask. | ||
setTimeout(() => this.updateOutlineGap()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this._ngZone.onStable.pipe(take(1)).subscribe(...)
work for this? You should also kick it out of the zone
1871760
to
1ba1a39
Compare
1ba1a39
to
7177637
Compare
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Fixes #12353 #12457 #11577