Drop down option to display all results

Hello,

I need some help with my code to get the dropdown to have an option that will display all results. I think I can do this by ‘resetting’ the filter, but I’m not having any luck with my code.

import wixData from ‘wix-data’;

$w.onReady( function () {
});

function groupType(){
let dropdownvalue = $w(“#dropdown1”).value;
$w(“#dataset1”).setFilter(wixData.filter().contains(‘job_role’, dropdownvalue))
}

export function dropdown1_change(event, $w){
groupType();
}

For those interested I found a post by Salman2301 who explained a simple code to get this result

$w.onReady( function () {
});

export function dropdown1_change(event){
let filterType = $w(‘#dropdown1’).value;
if (filterType === “nameofdropdownoptiontoselectall”){
$w(‘#dataset1’).setFilter(wixData.filter());
} else {
$w(‘#dataset1’).setFilter(wixData.filter().contains(“filtervaluenameindataset”, filterType));
}
}

How do i use this with my code
import wixData from ‘wix-data’ ;

$w . onReady ( function () {

$w ( '#dropdown1' ). onChange (() => { 
    **const**  selectedTag  =  $w ( '#dropdown1' ). value ; 

    **let**  filter  =  wixData . filter (); 

    **if**  ( selectedTag . length  >  0 ) { 
        filter  =  filter . hasSome ( "subtitle" ,  selectedTag ); 
    } 

    $w ( '#dataset1' ). setFilter ( filter ); 

}) 

});