Fix chevron icon rotation to use single 180-degree toggle

This commit is contained in:
Marcus Quinn
2025-03-16 02:12:35 +00:00
parent 2a446a5836
commit c126003d45

View File

@ -743,19 +743,29 @@ function wp_allstars_settings_page() {
<script>
jQuery(document).ready(function($) {
// Handle accordion functionality
$('.wp-allstars-expand-settings').on('click', function(e) {
e.preventDefault();
$('.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');
// Toggle panel
$panel.slideToggle(200, function() {
// Update state after animation completes
// Set initial state
var isExpanded = $panel.is(':visible');
$button.attr('aria-expanded', isExpanded);
$icon.css('transform', isExpanded ? 'rotate(180deg)' : 'rotate(0deg)');
$icon.css('transform', isExpanded ? 'rotate(180deg)' : '');
// Handle click events
$button.on('click', function(e) {
e.preventDefault();
// Toggle panel
$panel.slideToggle(200);
// Toggle state
isExpanded = !isExpanded;
$button.attr('aria-expanded', isExpanded);
// Update icon rotation
$icon.css('transform', isExpanded ? 'rotate(180deg)' : '');
});
});
});