Working with database connected dropdown

Hello, i have a dropdown selection connected to dataset to get its choices.

its a list of categories changed by year.

$w.onReady(function () {
$w("#categories").onReady( () => {console.log($w('#categories').getCurrentItem().category)}) //"CATEGORY A"
});
export function seasonslide_change(event) {  //Choose year
let season = $w('#seasonslide').currentSlide.name
$w("#categories").setFilter(wixData.filter().contains("title", season).eq("pos", 1).isNotEmpty("name"))
$w("#categories").onReady( () => {console.log($w('#categories').getCurrentItem().category)}) // Still "CATEGORY A" when CATEGORY B is expected
}

When i get different season with the seasonslide onChange, the function should filter the dataset with the new year, and get new set of categories, which the first one should be “Category B”, but i still get “Category A” and only when i change it again i’ll get the previous one. its like the filter is not happening yet, but i do use onReady for the dataset.

another problem is that somtimes its updating my dataset and changes it as the dataset is is in Read & Write premissions otherwise the dropdown is disabled.

any ideas?

Using the dataset onReady() is only needed in the page’s onReady() function. Using it in the seasonslide_change() is incorrect.

Also, before setting a new filter, try clearing the filter like this:

$w("#categories").setFilter( wixData.filter() );

I understand,
Than what I have to do to overcome the delay between the dataset filter to the drop-down update?