Sync two facets of different types with the same data source

<?php
// Syncs the selected values of two facets with different types when using one of the facets.
// The facets need to use the same Data Source.
// Change 'categories_radio' and 'categories_dropdown' to the names of your facets.
// Caveat: both facets will ghost each other's choices. This may not be optimal/desired.
// This can be fixed with the second snippet. Until a Dropdown facet has ghosts, this is not (yet) possible for Dropdowns.
add_action( 'facetwp_scripts', function() {
  ?>
  <script>
    document.addEventListener('facetwp-refresh', function() {
      if (null !== FWP.active_facet) {
        if ( 'categories_radio' == fUtil(FWP.active_facet.nodes[0]).attr('data-name' ) ) {
          FWP.facets['categories_dropdown'] = FWP.facets['categories_radio'];
        } else if ( 'categories_dropdown' == fUtil(FWP.active_facet.nodes[0]).attr('data-name' ) ) {
          FWP.facets['categories_radio'] = FWP.facets['categories_dropdown'];
        }
      }
    });
  </script>
  <?php
}, 100 );

// Optional: remove unclickable ghosts from the Radio facet
add_filter( 'facetwp_facet_html', function( $output, $params ) {
    if ( 'categories_radio' == $params['facet']['name'] ) { 
        $output = str_replace ( 'disabled' , '' , $output );
    }
    return $output;
}, 10, 2 );