Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust onSettle index of Bottomsheet (49) #947

Open
wants to merge 1 commit into
base: 49
Choose a base branch
from
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
12 changes: 11 additions & 1 deletion example/src/BottomSheetExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@ const BottomSheetExample: React.FC = () => {
const bottomSheetRef = React.useRef<any>();
return (
<View style={{ flex: 1 }}>
<BottomSheet style={{ alignItems: "center" }} ref={bottomSheetRef}>
<BottomSheet
style={{ alignItems: "center" }}
ref={bottomSheetRef}
onSettle={(newIndex: number) => {
try {
console.log("onSettle", newIndex);
} catch (error) {
console.error("Error in onSettle:", error);
}
}}
>
<Text>This is a bottom Sheet</Text>
</BottomSheet>
<Button
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/BottomSheet/BottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const BottomSheet = React.forwardRef<BottomSheetComponent, BottomSheetProps>(
borderWidth,
borderColor: borderColor ?? theme.colors.border.brand,
}}
onChange={(index) => onSettle?.(mappedSnapPoints.length - index - 1)}
onChange={(index) => onSettle?.(index)}
Copy link

Choose a reason for hiding this comment

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

The initialSnapIndex logic still uses the reversed index logic (mappedSnapPoints.length - initialSnapIndex - 1). This might lead to inconsistencies with the onSettle callback behavior. Consider aligning this logic with the new onChange behavior.

>
<BottomSheetScrollView
contentContainerStyle={[styles.contentContainerStyle, style]}
Expand Down
Loading