Giter Club home page Giter Club logo

Comments (11)

nkbt avatar nkbt commented on July 18, 2024

That is happening most likely because content height of your collapse cannot be determined. Maybe some styles are loaded with extra delay for example. In the example I have a situation with collapse opened by default and it closes smoothly. We also have bunch of examples in our project and they all work as expected.

Height measurement is pretty tricky, css-dependent and subject to many other odds. Sometimes you have to debug why that thing does not do what it should =(. Also there are some sacrifices in react-height for the sake of performance.

We also have react-element-resize which is not as performant but very accurate and sometimes we use it for vertical/horizontal animations. I need to figure out the way how to allow to use it instead of react-height when performance is not that critical (not when you render 1000 collapsible rows table, but some singled out blocks).

from react-collapse.

bdely avatar bdely commented on July 18, 2024

I just try by not having the children rendered and set the div inside the collapse element to 100px and it still closes instantly
Here is the my code for rendering the collapse component

if (typeof this.props.children !== 'undefined') {
     return <Collapse isOpened={ this.state.expanded } >
          <div className="treeview-children" style={{ height: '100px' }}></div>
     </Collapse>
}

from react-collapse.

nkbt avatar nkbt commented on July 18, 2024

I need more context to figure out what is not working in your case. This piece of code alone is not different for anything you can find in examples.

Everything actually matters. CSS too.

from react-collapse.

bdely avatar bdely commented on July 18, 2024

Would using rem and em cause this issue?

from react-collapse.

nkbt avatar nkbt commented on July 18, 2024

We use em/rems everywhere and do not have this problem.

See nkbt/react-height#11 - might be your case

from react-collapse.

jooj123 avatar jooj123 commented on July 18, 2024

I have this same issue when i set the keepCollapsedContent flag

from react-collapse.

nkbt avatar nkbt commented on July 18, 2024

Yeah, that is an issue

I reckon it happens because collapse renders content in this case (even if it is closed). It also sets defaultStyles to have height of the content and after that - changes it to 0.

Ideally defaultStyles should be removed entirely, tho it would mean some decent code refactoring.

Not sure I am able to spend my personal time for it these days (I have an extra project to finish).
And since in our work projects we do not use collapse in this way - there are no issues with collapse in last half a year and no issues to fix :(

Would be very very happy with PR to fix it.

from react-collapse.

nkbt avatar nkbt commented on July 18, 2024

Published

22:17 $ npm publish

> [email protected] prepublish /Users/nkbt/nkbt/react-collapse
> parallelshell -w "npm run build:lib -s" "npm run build:dist -s" "npm run build:min -s"

src/Collapse.js -> lib/Collapse.js
src/index.js -> lib/index.js
Hash: 81af8379a7c807940f49
Version: webpack 1.13.1
Time: 3765ms
                Asset     Size  Chunks             Chunk Names
    react-collapse.js    17 kB       0  [emitted]  main
react-collapse.js.map  21.2 kB       0  [emitted]  main
    + 8 hidden modules
Hash: 9bf68841c3a8ddfd7232
Version: webpack 1.13.1
Time: 3952ms
                    Asset     Size  Chunks             Chunk Names
    react-collapse.min.js   5.8 kB       0  [emitted]  main
react-collapse.min.js.map  40.7 kB       0  [emitted]  main
    + 8 hidden modules
+ [email protected]

Please, reopen if issue is still not fixed.

from react-collapse.

ilionic avatar ilionic commented on July 18, 2024

@nkbt I have same issue with version 2.3.3, and it sounds exactly like you described height measurement case. In my case I have nested Collapse components. Parent component is closed by default and children are open.
Another simpler use case is mounting components asynchronously, like

{loaded ? 
  <Collapse isOpened>
    <FiltersContainer />
  </Collapse>
}

Is there way around how to set / reset height explicitly?

collapse-jump 2

from react-collapse.

ilionic avatar ilionic commented on July 18, 2024

Actually version 3.2.0 works much better in this regard.

from react-collapse.

nkbt avatar nkbt commented on July 18, 2024

from react-collapse.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.