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): incorrect assumptions about page direction #17395

Merged
merged 1 commit into from
Dec 3, 2019

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Oct 14, 2019

These changes undo the changes from #15415 because they were making incorrect assumptions about the page starting off as LTR, and they were calling updateOutlineGap with an outdated value for the direction. This is causing issues like #17390.

I'm not totally sure what was being fixed by these changes, because the test that was added didn't fail even if I reverted all of the changes. From what I can tell the problem #15415 was trying to solve was that the outline gap might be updated too early on a direction change, before the browser has had the chance to recalculate the layout. These changes switch to recalculating inside a requestAnimationFrame after direction changes, in order to give the browser enough time to recalculate.

Fixes #17390.

@crisbeto crisbeto added 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 labels Oct 14, 2019
@crisbeto crisbeto requested a review from mmalerba as a code owner October 14, 2019 19:24
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Oct 14, 2019
These changes undo the changes from angular#15415 because they were making incorrect assumptions about the page starting off as LTR, and they were calling `updateOutlineGap` with an outdated value for the direction. This is causing issues like angular#17390.

I'm not totally sure what was being fixed by these changes, because the test that was added didn't fail even if I reverted all of the changes. From what I can tell the problem angular#15415 was trying to solve was that the outline gap might be updated too early on a direction change, before the browser has had the chance to recalculate the layout. These changes switch to recalculating inside a `requestAnimationFrame` after direction changes, in order to give the browser enough time to recalculate the layout.

Fixes angular#17390.
@crisbeto crisbeto force-pushed the form-field-dir-change branch from 0221ca5 to f759ca1 Compare October 14, 2019 19:39
this.updateOutlineGap();
this._previousDirection = this._dir.value;
if (typeof requestAnimationFrame === 'function') {
this._ngZone.runOutsideAngular(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this whole if-else be wrapped in runOutsideAngular? Currently it looks like it runs in the zone if the browser doesn't support requestAnimationFrame and outside if it does

Copy link
Member Author

Choose a reason for hiding this comment

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

updateOutlineGap doesn't do any zone-ey things, we only need to run requestAnimationFrame on the outside because it can trigger change detection otherwise.

@mmalerba mmalerba added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Oct 15, 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 Jan 3, 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.

Mat-form outline border
4 participants