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: Sticky offset in nested AppLayout #3013

Merged
merged 10 commits into from
Dec 4, 2024
Merged

fix: Sticky offset in nested AppLayout #3013

merged 10 commits into from
Dec 4, 2024

Conversation

georgylobko
Copy link
Contributor

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

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link

codecov bot commented Nov 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.34%. Comparing base (d1ff27e) to head (9a5290d).
Report is 3 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

…lVars.stickyVerticalTopOffset var in the dom element

useLayoutEffect(() => {
setIsNested(getIsNestedInAppLayout(rootRef.current));
}, []);
Copy link
Contributor Author

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

Copy link
Member

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?

Copy link
Contributor Author

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]);

Copy link
Member

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;

just-boris
just-boris previously approved these changes Dec 3, 2024
Copy link
Member

@just-boris just-boris left a 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;
Copy link
Member

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

Copy link
Contributor Author

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

Copy link
Member

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));
}, []);
Copy link
Member

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}>
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does

Copy link
Member

@just-boris just-boris left a 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

src/app-layout/visual-refresh-toolbar/index.tsx Outdated Show resolved Hide resolved
@georgylobko georgylobko added this pull request to the merge queue Dec 4, 2024
Merged via the queue into main with commit 40eb1f8 Dec 4, 2024
38 checks passed
@georgylobko georgylobko deleted the fix/sticky-offset branch December 4, 2024 14:12
cansuaa added a commit that referenced this pull request Dec 6, 2024
cansuaa added a commit that referenced this pull request Dec 9, 2024
jperals added a commit that referenced this pull request Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants