fSelect – automatically close dropdown after selection

<?php

// Add to your (child) theme's functions.php

add_action( 'wp_head', function() {
?>
<script>
document.addEventListener('facetwp-refresh', function() {
    if (! FWP.loaded) {
        FWP.hooks.addAction('facetwp/loaded', function() {
            fUtil('.facetwp-type-fselect .facetwp-dropdown').each(function() {
                fUtil(this).nodes[0].fselect.close();
            });
        }, 20);
    }
});
</script>
<?php
}, 100 );