fix(segmented_button): model index out of bounds when setting position

This commit is contained in:
Tony4dev 2024-12-03 05:14:33 +01:00 committed by GitHub
parent b80d90e5ce
commit d536341234
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -355,9 +355,10 @@ where
return None;
};
self.order.remove(index as usize);
let position = self.order.len().min(position as usize);
self.order.remove(index as usize);
self.order.insert(position, id);
Some(position)
}