Comments (11)
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.
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.
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.
Would using rem and em cause this issue?
from react-collapse.
We use em/rems everywhere and do not have this problem.
See nkbt/react-height#11 - might be your case
from react-collapse.
I have this same issue when i set the keepCollapsedContent
flag
from react-collapse.
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.
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.
@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?
from react-collapse.
Actually version 3.2.0 works much better in this regard.
from react-collapse.
from react-collapse.
Related Issues (20)
- as-prop for Collapse HOT 1
- Fade in/fade out with opacity style on open/close HOT 1
- hasNestedCollapse no longer necessary in v5 yet is used in Nested example HOT 1
- React-collapse does not work on some zoom levels (devicePixelRatio =1.25) Following up #238 HOT 1
- On collapse, .ReactCollapse--collapse element is being completely removed from the DOM
- Animation not working when the Collapse has a parent that it is in modal or something with position fixed HOT 2
- Financing
- The overflow for 'React-collapse--' is overflow:hidden , not overflow:initial for IE11 HOT 2
- Animation doesn't work HOT 5
- Collapse for table row HOT 3
- Starting mix-height HOT 7
- initialStyle not working HOT 3
- Collapse horizontally aligned content HOT 3
- Prop passing suggestion HOT 8
- Block stays expenaded with isOpened=false HOT 4
- Nested collapsible shows animation. Help needed HOT 4
- Collapse/Open all on button click? HOT 1
- Position sticky inside collapse HOT 8
- Is the component still maintained + proposed feature additions HOT 1
- CSS modules in React app won't affect the rendered Collapse HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-collapse.