-
Notifications
You must be signed in to change notification settings - Fork 4.1k
fix Fixes the clipping of IFrame when scrollIntoView is triggered #36833
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 Fixes the clipping of IFrame when scrollIntoView is triggered #36833
Conversation
Thanks for the pull request, @farhaanbukhsh! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. Where can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
68de72a
to
c988f77
Compare
@farhaanbukhsh Hi! Note Seems like my environment didn't pick up the change. When I tried again a couple of days latter, the issue was resolved as expected. Disregard the rest of the comment. clipping.mp4
I understand that scrollBy which runs on step 1 should correct this clipping, by moving the document down by 80px? I think the issue lies in the Iframe's height calculation. In the example below, we can see that the So, I manually set the height of the iframe to see if that would solve the issue. Interestingly, the document's body height increased as well 😕 Now, I am not sure if that's the issue for sure. Do you think investigating this could lead to a potential solution? |
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 tested this: Verified that the iframe is not clipped when autoscrolling.
- I read through the code
- I checked for accessibility issues
- Includes documentation
I am not sure what changed. I had a hunch, I needed to test this again and this time it worked.
@tecoholic That is great to know :), I think and this is what I wanted to add to the PR as well, did you build the assets so I generally exec in the container, lms/cms and run Hence, by chance, you have rebuilt the image and started the container that might have led to the code being run the right way. |
@farhaanbukhsh I am not sure. I remember doing a |
Fixes the clipping issue that is faced when triggering scrollIntoView. When a post message was made with scrollToXBlock the IFrame scrolled a bit more at the top, the fix resets the scroll. Signed-off-by: Farhaan Bukhsh <[email protected]>
c988f77
to
424b62f
Compare
@@ -176,6 +176,10 @@ function($, _, Backbone, gettext, BasePage, | |||
break; | |||
case 'scrollToXBlock': | |||
document.getElementById(data.payload.locator)?.scrollIntoView({behavior: "smooth"}); | |||
// This piece of code helps to avoid clipping the IFrame when scrollIntoView is triggered. | |||
setTimeout(() => { | |||
window.scrollBy(0, -80); |
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.
This looks brittle. I'd be more comfortable approving this if the underlying reason for the clipping were discovered, and the repositioning value, if necessary, were determined programatically. It's possible this could be solved with CSS, if we understood the problem better.
I believe I've found the root cause of this @arbrandes @tecoholic - this makes the iFrame size larger than it needs to be which is fine on initial load, but when 'scrollToXBlock' is called, the content within the iFrame gets shifted up and that's why we see the cutoff it's possible we could do |
@saraburns1 I can help you test the hypothesis since I think I have the setup. I wanted to let you know what I discovered if we agitate the UI, it re-renders and it switches to be okay. You can see this happening when the cut screen is rendered if we click around the area the UI renders and it becomes okay. Hence if we put a timeout and do a scrollBy with any value the UI just re-renders and becomes alright I found this when I was testing this PR after @arbrandes's comment. What I feel should be a polished solution is , when a postmessage gets to this point the |
@farhaanbukhsh @arbrandes - finally have a solution for this! We were scrolling the iFrame to the block location which caused the cutoff because the iFrame content was actually slightly larger than the container. Let me know if there are questions. If those PRs look reasonable, we can close this one |
Closing this in favour of the above comment. |
Fixed clipping issue faced when scrollToXBlock is triggered
Issues/Ticket: openedx/openedx-aspects#316
Discussions: Link to any public dicussions about this PR or the design/architecture. Otherwise omit this.
Dependencies: None
Screenshots: Always include screenshots if there is any change to the UI.
Sandbox URL: TBD - sandbox is being provisioned.
Merge deadline: "None" if there's no rush, "ASAP" if it's critical, or provide a specific date if there is one.
Testing instructions:
As mentioned in the ticket.