Repeater not sorting when a filter is active

Hi!

Basically I’m using a filter script connected to a dropdown menu to control what projects the repeater is showing.
I’ve set my repeater to sort the projects according to the order of the projects in the dataset. (not visual order but a value).
Before any filter is applied to the repeater the projects are sorted propperly, but once a filter is active the projects are sorted by date-created(which i read is default and not editable).

I would like the sorting order to apply for the repeater when any of the filters are active to keep it consistant. Any advice?

This is the script I’m using for the filter:

import wixData from 'wix-data';
 
const databaseName = 'DATABASENAME';
const databaseField = 'FIELDKEY';
 
$w.onReady(function () {
 
    $w('#tagID').onChange((event) => {
        const selectedTag = $w('#tagID').value;
        addItemstoRepeater(selectedTag);
    })
});
 
function addItemstoRepeater(selectedOption = []) {
 
    let dataQuery = wixData.query(databaseName);
 
    if (selectedOption.length > 0) {
        dataQuery = dataQuery.hasSome(databaseField, selectedOption);
    }
 
    dataQuery
        .find()
        .then(results => {
            const filtereditemsReady = results.items;
            $w('#repeaterID').data = filtereditemsReady;
 
        })
}
 

I’m using Editor X btw, if thats relevant info? I’m kinda new to this:)

Since your Repeater is connected to a dataset, using WixData code to filter the results creates a conflict. You should either filter using the Dataset , or disconnect the Repeater from the Dataset and initially populate the Repeater using WixData code.