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

[Bug]: dynamicOverlapHeight is not reset to baseline after table component unmounts #83

Closed
2 tasks done
agdimech opened this issue Jul 27, 2022 · 4 comments · Fixed by #84
Closed
2 tasks done
Labels
bug Something isn't working

Comments

@agdimech
Copy link

Browser

Chrome

Package version

3.0.1

React version

18.2.0

Description

I am using a Table component with a variant set to "full-page". I am using react-router to route to a detail page and I notice the dynamicOverlapHeight is retained when the detail page loads (--awsui-overlap-height-ujkcpl is present in

). When the Table (or any component that overrides these settings) unmounts, it should reset all of the default settings in the Layout to baseline.

Table uses an InternalContainer which appears to be the culprit: https://github.com/cloudscape-design/components/blob/main/src/container/internal.tsx#L59

I haven't tested but I assume to fix this we should change the layout callback as follows:

useLayoutEffect(
    function handleDynamicOverlapHeight() {
      if (hasDynamicHeight) {
        setDynamicOverlapHeight(overlapContainerQuery ?? 0);
      }
      return () => setDynamicOverlapHeight(0);
    },
    [hasDynamicHeight, overlapContainerQuery, setDynamicOverlapHeight]
  );

This should work as this code only overrides the offset if it is > 0:

dynamicOverlapHeight > 0 && { [customCssProps.overlapHeight]: `${dynamicOverlapHeight}px` }),

Source code

N/A

Reproduction

  • Create a table with full-page variant.
  • Add a link from the table to a new page using something like react-router.
  • The new page will preserve the offset set by the previous page which is not correct.

Code of Conduct

@agdimech agdimech added the bug Something isn't working label Jul 27, 2022
@FlorianDr
Copy link
Contributor

Hi Adrian,

thank you for reporting this bug. We created a fix (#84), which is currently in review.

Thank you again!

@agdimech
Copy link
Author

No problems - glad it was an easy fix which was my suspicion :)

@agdimech
Copy link
Author

Has this been merged into main?

@timogasda
Copy link
Member

Yes, this was merged into main. However, it might take some time until the change is released to npm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants