Adding an "All" option to dropdown's

Hi everyone,

I am developing a new page which has a repeater linked to a dataset and 3 dropdown list’s, which are populated from specific fields of the database to filter the data shown in the repeater - all of which works perfectly. However, I would like to add an ‘All’ option the each dropdown menu which when selected would reset that particular dropdown’s filter.

I thought this would be a simple process to sort but having spent much of today trying and failing, it clearly is anything but simple (for me anyway!). I’ve found this on this forum https://www.wix.com/velo/forum/main/comment/5b220420b55cc600145e5979 but I am struggling to fit it into my code, which as it stands is:

function uniqueDropDown1 (){
    wixData.query("HeritageNews")
        .limit(1000)
        .find()
        .then(results =>{
 
 const uniqueTitles = getUniqueTitles(results.items);
            $w('#newsType').options = buildOptions(uniqueTitles);
 
        });
 function getUniqueTitles(items) {
 
 const titlesOnly = items.map(item => item.title);
 
 
 return [...new Set(titlesOnly)];
 
    }   
 function buildOptions(uniqueList){
 
 
 return uniqueList.map(curr => {
 
 return {label:curr, value:curr};
 
        });
 
    }
}

function filter2 () {
    $w('#newsType').onChange((event) => {
 let title = $w('#newsType').value;
        $w('#dynamicDataset').onReady(() => {
            console.log("The dataset is ready to be filtered.");
if ($w('#newsType').value === "All"){
    $w('#dynamicDataset').setFilter();
}else {
    $w('#dynamicDataset').setFilter(wixData.filter()
 
    .eq("title", title)
    )
    .then(() => {
        console.log("Dataset is now filtered with the matching title from the dropdown");
 let getItem = $w('#repeater1').data
 
 
    })
    .catch((err) => {
        console.log(err);
    });
        }
    });
})
}

I’ve tried adding the code in the linked thread and have changed the optionsList part to other variations to suit my code but with no luck. Generally, it is either a case of the dropdown populating nothing or just populating the data from the field of the dataset without ever showing ‘Add’.

Could anyone assist with where I am going wrong on this one please?

Thanks