fix(content): apply --offset-top and --offset-bottom values correctly#20790
Merged
liamdebeasi merged 5 commits intomasterfrom Mar 24, 2020
Merged
fix(content): apply --offset-top and --offset-bottom values correctly#20790liamdebeasi merged 5 commits intomasterfrom
liamdebeasi merged 5 commits intomasterfrom
Conversation
Member
brandyscarney
left a comment
There was a problem hiding this comment.
Let me know if I need to elaborate on my comment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull request checklist
Please check if your PR fulfills the following requirements:
npm run build) was run locally and any changes were pushednpm run lint) has passed locally and any fixes were made for failuresPull request type
Please check the type of change your PR introduces:
What is the current behavior?
Issue Number: #20735
What is the new behavior?
In some cases,
ion-contentis rendered/hydrated before the root document element is hydrated. Because of https://github.com/ionic-team/ionic/blob/c15ae7cbf58065086816ca352c0a5ce981bb25b5/core/src/css/structure.scss#L25-L27 the root document element will havedisplay: none, causing theion-contentto be hidden. This also means itsoffsetParentwill benulland the element will have dimensions of 0x0. This is causing the--offset-topand--offset-bottomvariables to not be set with the correct values.To remedy this, I have created a MutationObserver that watched for attribute changes on
document.documentElement(usuallyhtml). The callback will recalculate the offset variable and then remove the observer if the root document element has thehydratedclass applied.In the event that
ion-contentis hydrated after the root document element, we still have thethis.resize()call incomponentDidLoad. If the root document element is already hydrated, the MutationObserver will not be created.Does this introduce a breaking change?
Other information