JSFiddle - React, Tailwind, and code Playground

by Arun Unnikrishnan

HTML

<div>
	<div class="page-header">
		<button id="menu">CLICK THIS</button>
	</div>
	<div id="leftpanel">
		<div id="accordion">
		    <h3>Heading 1</h3>
		    <div>
		      <p style="padding: 0; margin: 0; font-size: 0.7em;">See? heightStyle = "fill" doesn't fill the div.</p>
		    </div>
		    <h3>Heading 2</h3>
		    <div>
		      <p>Cras dictum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia mauris vel est. </p><p>Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. </p>
			</div>
		    <h3>Heading 3</h3>
		    <div>
		      <p>Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis. Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui. </p>
		    </div>
		    <h3>Heading 4</h3>
		    <div>
		      <p>Cras dictum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia mauris vel est. </p><p>Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. </p>
            </div>
	    </div><!--accordion-->
	</div><!-- #leftpanel -->
    <div id="map">Notice that height of this area fills the space just fine since it is displayed when the page loads, but when the above button is clicked, the accordion heightStyle="fill" does not do its job. <br>HOWEVER, watch when you click the button again- the property works as expected (only flashes briefly though, so I increased the transition...

CSS

body {
    padding: 0;
    margin: 0;
    color: #000;
}
.page-header {
    width: 100%;
    background: gray;
}
#menu {
    font-size: 1em;
    margin: 0.5em;
    font-weight: bold;
    cursor: pointer;
}
#leftpanel {
    display: none;
    background: blue;
    padding: 0;
    margin: 0;
    position: absolute;
    top: 3em;
    left: 0;
    bottom: 0;
    width: 100%;
}
#map {
    position: absolute;
    bottom: 0;
    top: 3em;
    width: 100%;
    background: yellow;
    line-height: 1.5em;
}

JavaScript

$(function() {
$( "#accordion" ).accordion({
	heightStyle: "fill",
  	collapsible: true
});
$( "#menu" ).click(function() {
    $( "#accordion" ).accordion( "refresh" );
    $( "#map" ).toggle({
        duration: 2000
    });
    $( "#leftpanel" ).toggle({
        duration: 2000
    });
        
});
});