Collapse / Expand Repeater based on the value of a text user input

w.onReady(function () {
      $w("#dataset1").onReady( () => {
} );
});

//search bar
import wixData from 'wix-data';

let debounceTimer;

export function input1_keyPress(event) {
 if (debounceTimer) {
        clearTimeout(debounceTimer);
        debounceTimer = undefined;
    }
    debounceTimer = setTimeout(() => {
        filter($w('#input1').value); // Here you are using your filter and giving the value with it. if you do this you should ask for a value in the filter function.
    }, 200);
}

let lastFilterTitle;
function filter() { //<--- should be filter(data)
$w('#dataset1').setFilter( 
wixData.filter() 
.contains("title", data) //<--- here i used the data that is given when you used the filter function
.and( wixData.filter() //<--- here is something wrong. you don't add any new data to be filtered. i think this can go away
) 
);

if($w("#input1").value === "title" ||$w("#input1").value === "title" ){

$w("#repeater1").expand()

} else {

$w("#repeater1").collapse()

}
}