Skip to content

(ExpandableTile): maxHeight calculation is wrong when component is mounted off viewport #7217

@jaknas

Description

@jaknas

What package(s) are you using?

  • carbon-components
  • carbon-components-react

Detailed description

Describe in detail the issue you're having.

Issue: If <ExpandableTile/> is placed offscreen, and mounted for example in a <Tab/>, then the calculation for its maxHeight is wrong.

tileMaxHeight: this.aboveTheFold.getBoundingClientRect().height,

It uses getBoundingClientRect() which returns 0 for all values, so the maxHeight is only calculated from padding:

: this.state.tileMaxHeight + this.state.tilePadding,

Is this issue related to a specific component?

Yes, ExpandableTile

What did you expect to happen? What happened instead? What would you like to
see changed?

I expected to have same height for both tiles, regardless whether they're inside a hidden component or visible normally.

Maybe the prop tileMaxHeight can be used to override this calculation?

What browser are you working in?

Chrome

What version of the Carbon Design System are you using?

newest

Steps to reproduce the issue

  1. Open codesandbox
  2. Switch between tabs, see that unfolded height is different for the same component

Please create a reduced test case in CodeSandbox

https://codesandbox.io/s/keen-bush-ztref?file=/src/index.js

Additional information

  • Screenshots or code

properly calculated height (when visible on mount)
image

when switching to second tab, wrong height for the same component. it should be the same as on the first tab

image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions