Utilizing bootstrap 3.3.7 panels, I encountered an issue when trying to slide up the panel using the icon. The panel would not hide properly once the panel height was set, resulting in only the panel content body sliding up. Here is an example:
$('.panel-collapse').on('click', function (e) {
var $this = $(this);
if (!$this.hasClass('panel-collapsed')) {
$this.parents('.panel').find('.panel-body').slideUp();
$this.addClass('panel-collapsed');
$this.find('i').removeClass('fa-chevron-up').addClass('fa-chevron-down');
} else {
$this.parents('.panel').find('.panel-body').slideDown();
$this.removeClass('panel-collapsed');
$this.find('i').removeClass('fa-chevron-down').addClass('fa-chevron-up');
}
});
.product-Section-panel
{
min-height: 280px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/
font-awesome/5.15.2/css/all.min.css"/>
<div class="col-sm-6 col-lg-6 col-xl-3">
<div class="panel panel-primary form-horizontal product-Section-panel">
<div class="panel-heading">
<h3 class="panel-title">
Panel 1
<a class="pull-right"><span class="panel-collapse"><i class="fa fa-chevron-up"> </i></span></a>
</h3>
</div>
<div class="panel-body">
<div class="form-group">
<label class="control-label">Label1</label>
<input type="text">
</div>
<div class="form-group">
<label class="control-label">Label1</label>
<input type="text">
</div>
<div class="form-group">
<label class="control-label">Label1</label>
<input type="text">
</div>
</div>
</div>
</div>
<div class="col-sm-6 col-lg-6 col-xl-3">
<div class="panel panel-primary form-horizontal product-Section-panel">
<div class="panel-heading">
<h3 class="panel-title">
Panel 1
<a class="pull-right"><span class="panel-collapse"><i class="fa fa-chevron-up"> </i></span></a>
</h3>
</div>
<div class="panel-body">
<div class="form-group">
<label class="control-label">Label1</label>
<input type="text">
</div>
<div class="form-group">
<label class="control-label">Label1</label>
<input type="text">
</div>
<div class="form-group">
<label class="control-label">Label1</label>
<input type="text">
</div>
</div>
</div>
</div>
To address this issue, I attempted setting the height on the panel-body as follows
<div class="panel-body product-Section-panel">
. However, this resulted in a loss of smooth animation. How can I set the panel height while maintaining smooth collapse functionality?