Hi. I am new here at Velo Coding and just thought if anyone could help me correct my code because even if I do not type any keyword in the search box and press enter key still it gives me search results.
import wixData from ‘wix-data’ ;
let debounceTimer ;
export function Search_keyPress ( event ) { //enable onKeypress for input form
if ( event . key === “Enter” ) {
$w ( "#clearSearch" ). show ( "fade" );
$w ( "#Search" ). value ;
**if** ( debounceTimer ) {
clearTimeout ( debounceTimer );
debounceTimer = **undefined** ;
}
debounceTimer = setTimeout (() => {
filter ( $w ( "#Search" ). value ); //ID of input form
}, 200 );
}
let searchWord ;
function filter ( search ) {
if ( searchWord !== search ) {
$w ( “#dataset1” ). setFilter ( wixData . filter (). contains ( ‘pen’ , search )); // ID of the dataset
searchWord = search ;
}
}
Appreciate your help in advance.