@yisrael-wix I resolved my issue by working with the existing indices (itemData._id) of the repeater. Renaming them is what causes problems (see my previous comment) - might want to communicate that to the teams.
Working prototype: https://thefashionsocietyh.editorx.io/website-11/page-3-mwe-new
var pos = Math.floor(nbItems/2);
$w("#repeater1").forEachItem(($item, itemData, index) => {
console.log(index);
console.log(itemData._id);
console.log($item("#box217"));
//if(index < obj_cp[0].Colors.Eye.length){
$item("#box217").style.backgroundColor = obj_cp[0].Colors.Eye[index];
$item("#box217").style.borderWidth = "4px";
if(index === pos) {
$item("#box217").style.borderColor = "rgb(0,0,0)";
} else {
$item("#box217").style.borderColor = "rgb(255,255,255)";
}
//}
});
var item;
var firstColor;
$w("#button156").onClick( (event) => { //switch position of colors
$w("#repeater1").forEachItem(($item, itemData, index_i) => {
if(index_i === 0){
firstColor = $item("#box217").style.backgroundColor;
console.log("firstColor:")
console.log(firstColor)
$w("#repeater1").forEachItem(($item, itemData, index_j) => {
if(index_j < nbItems-1) {
//select item to the right
item = $w("#repeater1").data[index_j+1]._id;
console.log("nextItem:");
console.log(item);
var bgColor;
$w("#repeater1").forItems( [item], ($item, itemData, index) => {
bgColor = $item("#box217").style.backgroundColor
});
//current item
item = $w("#repeater1").data[index_j]._id;
console.log("currItem:");
console.log(item);
$w("#repeater1").forItems( [item], ($item, itemData, index) => {
$item("#box217").style.backgroundColor = bgColor;
});
}
});
//store first element in last pos
item = $w("#repeater1").data[nbItems-1]._id;
$w("#repeater1").forItems( [item], ($item, itemData, index) => {
$item("#box217").style.backgroundColor = firstColor;
});
}
});
});