-
Notifications
You must be signed in to change notification settings - Fork 162
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: Sticky offset in nested AppLayout #3013
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3013 +/- ##
========================================
Coverage 96.34% 96.34%
========================================
Files 779 779
Lines 21913 21928 +15
Branches 7502 7104 -398
========================================
+ Hits 21112 21127 +15
- Misses 749 794 +45
+ Partials 52 7 -45 ☔ View full report in Codecov by Sentry. |
f67ada2
to
23c016d
Compare
40873b8
to
1b24bf7
Compare
…lVars.stickyVerticalTopOffset var in the dom element
|
||
useLayoutEffect(() => { | ||
setIsNested(getIsNestedInAppLayout(rootRef.current)); | ||
}, []); |
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.
@just-boris you previously suggested to skip this calculation if toolbar is empty, but it turns out this performance optimization might even backfire if we put it as a dependency here, since it will be recalculated every time this prop changes, so I decided to leave it as is
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 do not understand this comment. Could you post here in the comments a possible code how you planned to handle the toolbar and which dependency concerned you?
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.
useLayoutEffect(() => {
if (toolbarProps) {
setIsNested(getIsNestedInAppLayout(rootRef.current));
}
}, [toolbarProps]);
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.
How about using hasToolbar
value. It is boolean and rarely changes:
const hasToolbar = !embeddedViewMode && !!toolbarProps; |
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.
Approved, but it would be great to address the comments
if (getComputedStyle(currentElement).getPropertyValue(globalVars.stickyVerticalTopOffset)) { | ||
return true; | ||
} | ||
currentElement = currentElement.parentElement; |
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.
CSS var values propagate. You do not need to manually walk up
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.
Technically, the decision suggested by you is better, but it does not work in u tests env so I turned it back
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.
Okay, so getComputedStyle
implementation is JSDOM is more naive.
Let's leave a comment for the future readers this loop is needed for JSDOM.
Fine to keep it because in the real browsers it will exit after the first iteration anyway
|
||
useLayoutEffect(() => { | ||
setIsNested(getIsNestedInAppLayout(rootRef.current)); | ||
}, []); |
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 do not understand this comment. Could you post here in the comments a possible code how you planned to handle the toolbar and which dependency concerned you?
|
||
export default function () { | ||
return ( | ||
<ScreenshotArea gutters={false}> |
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.
Need to ensure this dev page passes new integration tests added there: #3063
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.
It does
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.
Last one and then approved
Co-authored-by: Boris Serdiuk <[email protected]>
Description
Keep table's sticky header within a nested AppLayout on scroll by resetting globalVars.stickyVerticalTopOffset and globalVars.stickyVerticalBottomOffset for nested layout.
Related links, issue #, if available: n/a
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
checkSafeUrl
function.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.