Home › Forums › Gutenberg › ACF blocks cramped in right sidebar of editor › Reply To: ACF blocks cramped in right sidebar of editor
As a quick fix, I tried this solution where you increase the width of the block panel upon clicking on a “.wp-block” element.This way, the panel expands and the ACF fields are more accessible and big enough to enter the content. Clicking on the top panel exits the mode.
Please feel free to improve the code and use percentage based width if required.
Javascript:
window.addEventListener("load", function (event) {
var wp_blocks_list = document.getElementsByClassName('wp-block');
var get_tool_bar = document.getElementsByClassName('edit-post-header__toolbar');
for (var i = 0; i < wp_blocks_list.length; i++) {
this.addEventListener('click', elementclick, true);
}
get_tool_bar[0].addEventListener('click', function () {
document.body.classList.remove('widen');
})
});
function elementclick() {
if (!document.body.classList.contains('widen')) {
document.body.className += ' widen';
}
}
CSS:
.widen .edit-post-sidebar{
width: 500px;
}
Functions:
function widen_block_panel_script($hook) {
if ('post.php' !== $hook) {
return;
}
wp_enqueue_script('custom-admin-js', get_stylesheet_directory_uri(). '/custom-admin.js');
}
add_action('admin_enqueue_scripts', 'widen_block_panel_script');
add_action('admin_head', 'widen_block_panel_style');
function widen_block_panel_style() {
echo '<style>
.widen .edit-post-sidebar{
width: 500px;
}
</style>';
}
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!
CPT registration is coming to ACF! We demoed the new feature during the most recent session of ACF Chat Fridays. Check out the summary for the details. https://t.co/k2KQ3WWBAz
— Advanced Custom Fields (@wp_acf) March 7, 2023
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.