Why the repeater show the first element of a dataset for a second and then the filtering result of dataset?

Here is the coding for the first page, search criteria.

// Velo API 參考: https://www.wix.com/velo/reference/api-overview/introduction
import wixData from "wix-data";
import {session} from 'wix-storage';
import wixLocation from 'wix-location';
import { authentication, currentMember } from 'wix-members';

 let loginemail;

$w.onReady(function () {

    $w.onReady(function () {
  const loggedIn = authentication.loggedIn();

  if (loggedIn) {
    console.log('Logged in, showing the logout button');
 
  }

currentMember.getMember()
  .then((member) => {
    const id = member._id;
    const fullName = `${member.contactDetails.firstName} ${member.contactDetails.lastName}`;
     loginemail = `${member.loginEmail}`;
    return member;
  })
  .catch((error) => {
    console.error(error);
  });
  
  export async function button1_click(event, $w) {
    session.clear;
    
let lastFilterCountry=$w('#ddlCountry').value;
let lastProductType=$w('#ddlProductType').value;
let lastProductName=$w('#txtProductName').value;
let lastProjectDate=$w('#datePickerProject').value;

let newHistory = {

    email:loginemail,
    country:lastFilterCountry,
    productType: lastProductType,
    productName:lastProductName,
    projectDate:lastProjectDate
    
}
    // This function was added from the Properties & Events panel. To learn more, visit http://wix.to/UcBnC-4
    // Add your code for this event here: 
    //console.log (lastFilterCountry);
    
    console.log ("loginemail" + loginemail);
    console.log ("new lastFilterCountry "+ lastFilterCountry );

    session.setItem("country",lastFilterCountry );
        wixData.insert("History", newHistory);
  

    wixLocation.to("services/items");
}

Here is the coding for the second page, to show the search result.

// Velo API 參考: https://www.wix.com/velo/reference/api-overview/introduction
import wixData from "wix-data";
import {session} from 'wix-storage';
import wixLocation from 'wix-location';
$w.onReady(function () {

let countrySelected =session.getItem("country" );
console.log( countrySelected);

     $w('#dataset1').onReady;
     $w('#dataset1').setFilter(wixData.filter().contains("country",countrySelected));
     $w('#repeater1').expand();
   
  

});

Because your code seems to be wrong, at least not 100% OK.

  1. Never use more then just → 1x $w.onReady() - command ← on your page.

Here an example where you do not follow that rule…

import wixData from "wix-data";
import {session} from 'wix-storage';
import wixLocation from 'wix-location';
import { authentication, currentMember } from 'wix-members';


let loginemail;

$w.onReady(function() {
    $w.onReady(function() {
        const loggedIn = authentication.loggedIn();

        if (loggedIn) {console.log('Logged in...');}
        //.....
        //....
        //...
        //..
        //:
  1. Another problem in your code found here…

WRONG !!!


import {session} from 'wix-storage';
import wixLocation from 'wix-location';

$w.onReady(function() {
    let countrySelected = session.getItem("country" );
    console.log( countrySelected);

    $w('#dataset1').onReady;
    $w('#dataset1').setFilter(wixData.filter().contains("country",countrySelected));
    $w('#repeater1').expand();
});

RIGHT !!!

import wixData from "wix-data";
import {session} from 'wix-storage';
import wixLocation from 'wix-location';

$w.onReady(function() {
    let countrySelected = session.getItem("country" );
    console.log("Selected-Country: ", countrySelected);

    $w('#dataset1').onReady(()=>{
        $w('#dataset1').setFilter(wixData.filter().contains("country",countrySelected));
        $w('#repeater1').expand();
    });
});