Fix accordion panel state handling to ensure proper open/close behavior
This commit is contained in:
@ -742,6 +742,24 @@ 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
|
||||||
$('.wp-allstars-expand-settings').on('click', function(e) {
|
$('.wp-allstars-expand-settings').on('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@ -750,7 +768,7 @@ 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';
|
||||||
|
|
||||||
// Update state before animation
|
// Toggle state
|
||||||
isExpanded = !isExpanded;
|
isExpanded = !isExpanded;
|
||||||
$button.attr('aria-expanded', isExpanded);
|
$button.attr('aria-expanded', isExpanded);
|
||||||
$icon.css('transform', isExpanded ? 'rotate(180deg)' : '');
|
$icon.css('transform', isExpanded ? 'rotate(180deg)' : '');
|
||||||
|
Reference in New Issue
Block a user