Fix accordion behavior to properly stay open/closed following WordPress patterns
This commit is contained in:
@ -742,26 +742,27 @@ function wp_allstars_settings_page() {
|
||||
|
||||
<script>
|
||||
jQuery(document).ready(function($) {
|
||||
// Set initial state
|
||||
$('.wp-allstars-toggle-settings').hide();
|
||||
|
||||
// Handle accordion functionality
|
||||
$('.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');
|
||||
|
||||
// Toggle panel visibility
|
||||
$panel.stop().slideToggle(200);
|
||||
|
||||
// Toggle aria-expanded
|
||||
var isExpanded = $button.attr('aria-expanded') === 'true';
|
||||
|
||||
// Toggle aria state
|
||||
$button.attr('aria-expanded', !isExpanded);
|
||||
|
||||
// Rotate icon
|
||||
$icon.css('transform', !isExpanded ? 'rotate(180deg)' : '');
|
||||
|
||||
// Toggle panel visibility with animation
|
||||
if (!isExpanded) {
|
||||
$panel.css('display', 'block').hide().slideDown(200);
|
||||
} else {
|
||||
$panel.slideUp(200);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user