Fix accordion panel to properly stay open/closed while preserving chevron rotation
This commit is contained in:
@ -742,23 +742,6 @@ function wp_allstars_settings_page() {
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
jQuery(document).ready(function($) {
|
jQuery(document).ready(function($) {
|
||||||
// Set initial state without animation
|
|
||||||
$('.wp-allstars-expand-settings').each(function() {
|
|
||||||
var $button = $(this);
|
|
||||||
var $panel = $button.closest('.wp-allstars-toggle').find('.wp-allstars-toggle-settings');
|
|
||||||
var $icon = $button.find('.dashicons');
|
|
||||||
var isExpanded = $button.attr('aria-expanded') === 'true';
|
|
||||||
|
|
||||||
// Set initial state
|
|
||||||
if (isExpanded) {
|
|
||||||
$panel.show();
|
|
||||||
$icon.css('transform', 'rotate(180deg)');
|
|
||||||
} else {
|
|
||||||
$panel.hide();
|
|
||||||
$icon.css('transform', '');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Handle click events
|
// Handle click events
|
||||||
$('.wp-allstars-expand-settings').on('click', function(e) {
|
$('.wp-allstars-expand-settings').on('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@ -768,13 +751,18 @@ function wp_allstars_settings_page() {
|
|||||||
var $icon = $button.find('.dashicons');
|
var $icon = $button.find('.dashicons');
|
||||||
var isExpanded = $button.attr('aria-expanded') === 'true';
|
var isExpanded = $button.attr('aria-expanded') === 'true';
|
||||||
|
|
||||||
// Toggle state
|
// Update state
|
||||||
isExpanded = !isExpanded;
|
$button.attr('aria-expanded', !isExpanded);
|
||||||
$button.attr('aria-expanded', isExpanded);
|
|
||||||
$icon.css('transform', isExpanded ? 'rotate(180deg)' : '');
|
|
||||||
|
|
||||||
// Animate panel
|
// Update icon (keep the working rotation logic)
|
||||||
$panel.slideToggle(200);
|
$icon.css('transform', !isExpanded ? 'rotate(180deg)' : '');
|
||||||
|
|
||||||
|
// Toggle panel with animation
|
||||||
|
if (!isExpanded) {
|
||||||
|
$panel.slideDown(200);
|
||||||
|
} else {
|
||||||
|
$panel.slideUp(200);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Reference in New Issue
Block a user