fix: Rigorizing the isStuck logic in container use-sticky-header#3239
Merged
fix: Rigorizing the isStuck logic in container use-sticky-header#3239
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3239 +/- ##
=======================================
Coverage 96.44% 96.44%
=======================================
Files 791 791
Lines 22568 22568
Branches 7385 7385
=======================================
Hits 21765 21765
Misses 796 796
Partials 7 7 ☔ View full report in Codecov by Sentry. |
1e73999 to
6e5000c
Compare
6e5000c to
cf7fbfb
Compare
cf7fbfb to
5df9a5a
Compare
2d9963e to
7630ced
Compare
dpitcock
commented
Feb 5, 2025
dpitcock
commented
Feb 5, 2025
avinashbot
reviewed
Feb 6, 2025
f2a71f3 to
a51ee04
Compare
avinashbot
approved these changes
Feb 6, 2025
georgylobko
pushed a commit
that referenced
this pull request
Feb 18, 2025
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.
Description
The previous isStuck logic was causing some unintended visual issues. When the isStuck condition was falsey set to true, it was removing the border radius on an internal element. This caused that element to overlay on top of its parent container, hiding the curved borders on the corners. This problem became more noticeable when the screen was viewed at different zoom levels.
The isStuck was being falsely set to true because why the top pixel values from sequentially calling
.getBoundingClientRect()on a parent and nested child element might not return the same values, even if they are in the same position. Here are some reasons as to why:.getBoundingClientRect()method returns the size and position of the element relative to the viewport, and this can change slightly between the two calls if the element is being scrolled or resized during that time. This is especially true if the function is being called on scroll, as the element's position may have shifted slightly between the two calls..getBoundingClientRect()are in pixels, but there can be small differences in the decimal places due to browser rounding and the way floating-point numbers are represented in JavaScript. This can result in slight discrepancies, even if the elements are in the same position.To mitigate the issue, I wrap the returned values in a
Math.round()function as I noticed the differences were often in the .00001's of pixels. This seems to resolve the issue.Related links, issue #, if available: AWSUI-60267
How has this been tested?
Review checklist
The following items are to be evaluated by the author(s) and the reviewer(s).
Correctness
CONTRIBUTING.md.CONTRIBUTING.md.Security
checkSafeUrlfunction.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.