Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@babel/preset-typescript": "^7.28.5",
"@babel/runtime": "^7.29.2",
"@changesets/cli": "^2.27.1",
"@shopify/flash-list": "^2.3.1",
"babel-jest": "^29.7.0",
"metro-react-native-babel-preset": "^0.77.0",
"react-test-renderer": "19.2.0",
Expand Down
45 changes: 28 additions & 17 deletions packages/ui/dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/ui/dist/index.js.map

Large diffs are not rendered by default.

45 changes: 28 additions & 17 deletions packages/ui/dist/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ function AnimatedListInner({
ref,
data,
renderItem: (info) => /* @__PURE__ */ React4.createElement(AnimatedCell, { ...info }),
keyExtractor: (item, index) => item?.id || item?.key || String(index),
...flashListProps,
contentContainerStyle: useMemo3(() => [
animatedList.container,
Expand Down Expand Up @@ -3712,6 +3713,8 @@ function Marquee({
const translateX = useSharedValue7(0);
const translateY = useSharedValue7(0);
const isPaused = useSharedValue7(false);
const [containerSize, setContainerSize] = React43.useState(0);
const [contentSize, setContentSize] = React43.useState(0);
const animatedStyle = useAnimatedStyle9(() => {
if (direction === "left" || direction === "right") {
return {
Expand Down Expand Up @@ -3771,27 +3774,19 @@ function Marquee({
};
const resumeAnimation = () => {
isPaused.value = false;
measureAndStart();
};
const measureAndStart = () => {
containerRef.current?.measure((x, y, width, height) => {
contentRef.current?.measure((cx, cy, cWidth, cHeight) => {
if (direction === "left" || direction === "right") {
startAnimation(width, cWidth);
} else {
startAnimation(height, cHeight);
}
});
});
if (containerSize > 0 && contentSize > 0) {
startAnimation(containerSize, contentSize);
}
};
useEffect3(() => {
const timeout = setTimeout(measureAndStart, 100);
if (containerSize > 0 && contentSize > 0) {
startAnimation(containerSize, contentSize);
}
return () => {
clearTimeout(timeout);
cancelAnimation(translateX);
cancelAnimation(translateY);
};
}, [children, speed, direction, loop]);
}, [containerSize, contentSize, speed, direction, loop]);
const handlePressIn = () => {
if (pauseOnPress) {
pauseAnimation();
Expand All @@ -3810,7 +3805,15 @@ function Marquee({
style: styles11.container,
accessibilityLabel,
accessibilityRole: "text",
testID
testID,
onLayout: (e) => {
const { width, height } = e.nativeEvent.layout;
if (direction === "left" || direction === "right") {
setContainerSize(width);
} else {
setContainerSize(height);
}
}
},
fadeEdges && /* @__PURE__ */ React43.createElement(React43.Fragment, null, /* @__PURE__ */ React43.createElement(
View39,
Expand Down Expand Up @@ -3841,6 +3844,14 @@ function Marquee({
],
onTouchStart: handlePressIn,
onTouchEnd: handlePressOut,
onLayout: (e) => {
const { width, height } = e.nativeEvent.layout;
if (direction === "left" || direction === "right") {
setContentSize(width);
} else {
setContentSize(height);
}
},
accessible: false
},
children
Expand Down Expand Up @@ -4935,7 +4946,7 @@ function SegmentedControl({
transform: [{ translateX: translateX.value }],
width: indicatorWidth.value
}));
const showIndicator = layoutReady && segmentWidth > 0;
const showIndicator = layoutReady && segmentWidth > 0 && containerWidth > 0;
return /* @__PURE__ */ React54.createElement(
View49,
{
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/dist/index.mjs.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/ui/src/components/AnimatedList/AnimatedList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ function AnimatedListInner<T>(
ref={ref}
data={data}
renderItem={(info: any) => <AnimatedCell {...info} />}
keyExtractor={(item: any, index: number) => item?.id || item?.key || String(index)}

@cubic-dev-ai cubic-dev-ai Bot Apr 4, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Use nullish coalescing for key fallback so valid falsy IDs (e.g. 0) are not replaced by index-based keys.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/ui/src/components/AnimatedList/AnimatedList.tsx, line 108:

<comment>Use nullish coalescing for key fallback so valid falsy IDs (e.g. 0) are not replaced by index-based keys.</comment>

<file context>
@@ -105,6 +105,7 @@ function AnimatedListInner<T>(
             ref={ref}
             data={data}
             renderItem={(info: any) => <AnimatedCell {...info} />}
+            keyExtractor={(item: any, index: number) => item?.id || item?.key || String(index)}
             {...flashListProps}
             contentContainerStyle={useMemo(() => [
</file context>
Suggested change
keyExtractor={(item: any, index: number) => item?.id || item?.key || String(index)}
keyExtractor={(item: any, index: number) => String(item?.id ?? item?.key ?? index)}
Fix with Cubic

{...flashListProps}
contentContainerStyle={useMemo(() => [
animatedList.container,
Expand Down
45 changes: 27 additions & 18 deletions packages/ui/src/components/Marquee/Marquee.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ export function Marquee({
const translateY = useSharedValue(0);
const isPaused = useSharedValue(false);

const [containerSize, setContainerSize] = React.useState(0);
const [contentSize, setContentSize] = React.useState(0);

const animatedStyle = useAnimatedStyle(() => {
if (direction === "left" || direction === "right") {
return {
Expand Down Expand Up @@ -130,31 +133,21 @@ export function Marquee({

const resumeAnimation = () => {
isPaused.value = false;
// Re-measure and restart animation
measureAndStart();
};

const measureAndStart = () => {
containerRef.current?.measure((x, y, width, height) => {
contentRef.current?.measure((cx, cy, cWidth, cHeight) => {
if (direction === "left" || direction === "right") {
startAnimation(width, cWidth);
} else {
startAnimation(height, cHeight);
}
});
});
// Restart animation using existing dimensions
if (containerSize > 0 && contentSize > 0) {
startAnimation(containerSize, contentSize);
}
};

useEffect(() => {
// Start animation after layout
const timeout = setTimeout(measureAndStart, 100);
if (containerSize > 0 && contentSize > 0) {
startAnimation(containerSize, contentSize);
}
return () => {
clearTimeout(timeout);
cancelAnimation(translateX);
cancelAnimation(translateY);
};
}, [children, speed, direction, loop]);
}, [containerSize, contentSize, speed, direction, loop]);

const handlePressIn = () => {
if (pauseOnPress) {
Expand All @@ -177,6 +170,14 @@ export function Marquee({
accessibilityLabel={accessibilityLabel}
accessibilityRole="text"
testID={testID}
onLayout={(e) => {
const { width, height } = e.nativeEvent.layout;
if (direction === "left" || direction === "right") {
setContainerSize(width);
} else {
setContainerSize(height);
}
}}
>
{fadeEdges && (
<>
Expand Down Expand Up @@ -204,6 +205,14 @@ export function Marquee({
]}
onTouchStart={handlePressIn}
onTouchEnd={handlePressOut}
onLayout={(e) => {
const { width, height } = e.nativeEvent.layout;
if (direction === "left" || direction === "right") {
setContentSize(width);
} else {
setContentSize(height);
}
}}
accessible={false} // Let parent handle accessibility
>
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export function SegmentedControl({
width: indicatorWidth.value,
}));

const showIndicator = layoutReady && segmentWidth > 0;
const showIndicator = layoutReady && segmentWidth > 0 && containerWidth > 0;

return (
<View
Expand Down