Fix accordion panel state handling to ensure proper open/close behavior

This commit is contained in:
Marcus Quinn
2025-03-16 02:21:41 +00:00
parent cd3bae732b
commit 2f11132157

View File

@ -742,6 +742,24 @@ function wp_allstars_settings_page() {
<script>
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
$('.wp-allstars-expand-settings').on('click', function(e) {
e.preventDefault();
@ -750,7 +768,7 @@ function wp_allstars_settings_page() {
var $icon = $button.find('.dashicons');
var isExpanded = $button.attr('aria-expanded') === 'true';
// Update state before animation
// Toggle state
isExpanded = !isExpanded;
$button.attr('aria-expanded', isExpanded);
$icon.css('transform', isExpanded ? 'rotate(180deg)' : '');