Repeater filter works for desktop, but not mobile

I have a repeater that can be filtered using a dropdown menu and a text input box. I want a default filter when the page is first loaded. I’ve created a default filter function by creating the filter in the $w.onReady() function. It works perfectly as intended on desktop, however on mobile it does not. It does not have the default filter and the repeater is simply populated in the order the items appear in the database. I’d appreciate any help, code is below:
import wixData from ‘wix-data’;

$w.onReady(() => {
wixData.query()
.find()
.then(res => {
let options = [{“value”: ‘’, ‘label’: ‘All Days’}];
options.push(…res.items.map(day => {
return {‘value’: day.title, ‘label’: day.title};
}));
$w(‘#iDay’).options = options;
})
let defaultFilter = wixData.filter().contains(‘promoted’,“p”);
$w(‘#dynamicDataset’).setFilter(defaultFilter);

});

let lastKeywordList;
let lastFilterDay;

let debounceTimer;
export function iKeyword_keyPress(event, $w) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}

debounceTimer = setTimeout(() => {
//console.log($w(‘#iKeyword’).value);
//console.log($w(‘#iDay’).value);
let keywordList = ($w(‘#iKeyword’).value).split(" ");
filter(keywordList, lastFilterDay);
},900);

}

function filter(keywordList, day) {
if (lastKeywordList !== keywordList || lastFilterDay !== day){
let newFilter = wixData.filter();
if (keywordList){
let i;
for (i=0; i < keywordList.length; i++){
newFilter = newFilter.contains(‘keywords’,keywordList[i]);
}
}
if (day){
newFilter = newFilter.contains(‘day’,day);
}
$w(‘#dynamicDataset’).setFilter(newFilter);
lastKeywordList = keywordList;
lastFilterDay = day;
$w(‘#dynamicDataset’).setSort(wixData.sort().descending(‘promoted’));
}
}
export function iDay_change(event, $w) {
filter(lastKeywordList, $w(‘#iDay’).value);
}

Website link is: https://matthewliscia.wixsite.com/dailydeals/DailyDeals
The goal is to have only the “promoted” deals as the default filter. Again it works on desktop but not mobile.

I can’t test the mobile version, because I don’t know how to force your Wix-Page to go to Mobile-Version.
But I think your code looks correct… I have multi filter system on my page and that works fine on mobile.

Anyway my question: Is the dropdown-filter working on mobile? Or is it the search-filter?

The dropdown and search filters work exactly as intended on desktop and on mobile. The main issue I am encountering is that the default filter is not being applied when the page is loaded on mobile. When I open it on desktop it functions correctly and only shows items that are “promoted”. This does not happen on mobile. It does work when I do a mobile preview of the page on the desktop editor.

Actually, now that I visited the website on another computer, it seems as though the default filter is not working. It works on some computers but not others. I guess my main question is how can I set a default filter? Calling the filter function in the $w.onReady() function seems to work some of the time, but I need consistency.

Hmm?!
What I do not understand, why you have some Timeout in our code.

There is a “Example”-Tutorial with Search-Field and Dropdwon-Filter from Wix-Moderator ( https://www.wix.com/corvid/profile/yisrael-wix/profile ). You should have a closer look to that example.

UPDATE: I found it: https://www.wix.com/corvid/forum/corvid-tips-and-updates/example-remove-duplicates-from-connected-dropdown-options-using-distinct-query :wink: