Fix accordion panel toggle with simplified, more reliable approach

This commit is contained in:
Marcus Quinn
2025-03-16 02:26:46 +00:00
parent e50f82ed70
commit cf3235984a

View File

@ -742,27 +742,26 @@ function wp_allstars_settings_page() {
<script>
jQuery(document).ready(function($) {
// Handle click events
// Set initial state
$('.wp-allstars-toggle-settings').hide();
$('.wp-allstars-expand-settings').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
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';
// Update state
// Toggle panel visibility
$panel.stop().slideToggle(200);
// Toggle aria-expanded
var isExpanded = $button.attr('aria-expanded') === 'true';
$button.attr('aria-expanded', !isExpanded);
// Update icon (keep the working rotation logic)
// Rotate icon
$icon.css('transform', !isExpanded ? 'rotate(180deg)' : '');
// Toggle panel with animation
if (!isExpanded) {
$panel.slideDown(200);
} else {
$panel.slideUp(200);
}
});
});
</script>