How to prevent the dropdown from closing when using a form in the Menu Builder

Pressing the space key in a form located inside a dropdown created using the Menu Builder, will always close the dropdown, preventing proper usage of the form.

To fix that issue, add this Javascript (In a Code Block or the in Global Settings / Code / Javascript ) :

const formInsideDropdown = document.querySelector('.breakdance-menu');
formInsideDropdown.addEventListener('keydown', function(event) {
if (event.code === 'Space' && event.target.matches('input, textarea, select')) {
// Prevent the dropdown from toggling when spacebar is pressed inside an input, textarea or select element
event.stopPropagation();
}
}, true);