Home › Forums › Feature Requests › Flexible content fields – global expand and collapse › Reply To: Flexible content fields – global expand and collapse
I messed around with a code to collapse with shift-click on Flexible Content ‘headers’. Shift-click felt more natural than a button somewhere on the page.
It also works with the pretty-edit-pen icon from ACF Extended. Not further tested on other Extended settings.
It checks if the currently clicked header is open/closed, and applies open/close to all other elements accordingly. Some weird timeout function was required not to interfere with (probably) default click behaviour?
For anyone interested you can add this to admin JS:
// Function to handle shift+click event on .acf-fc-layout-handle
$('.acf-fc-layout-handle').on('click', function(e) {
if (e.shiftKey) {
e.preventDefault();
closestLayout = $(this).closest('.layout');
if (closestLayout.hasClass('-collapsed')) {
// console.log('Layout is hidden');
setTimeout(function(){
$('.acf-flexible-content .values .layout').removeClass('-collapsed');
$('.acf-flexible-content .acfe-fc-placeholder').addClass('acf-hidden');
}, 1);
} else {
// console.log('Layout is visible');
setTimeout(function(){
$('.acf-flexible-content .values .layout').addClass('-collapsed');
$('.acf-flexible-content .acfe-fc-placeholder').removeClass('acf-hidden');
}, 1);
}
}
});
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.