From 04dd8f9eefcaea1c50cee6a5ec7ebc3b528e0669 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Mon, 19 Feb 2024 15:49:22 -0600 Subject: [PATCH] Comments --- src/components/Dialog/index.tsx | 9 +++++++++ src/components/Dialog/types.ts | 10 +++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/components/Dialog/index.tsx b/src/components/Dialog/index.tsx index 329d3c47ac..f30d24e6ac 100644 --- a/src/components/Dialog/index.tsx +++ b/src/components/Dialog/index.tsx @@ -35,11 +35,20 @@ export function Outer({ const sheetOptions = nativeOptions?.sheet || {} const hasSnapPoints = !!sheetOptions.snapPoints const insets = useSafeAreaInsets() + + /* + * Used to manage open/closed, but index is otherwise handled internally by `BottomSheet` + */ const [openIndex, setOpenIndex] = React.useState(-1) + + /* + * `openIndex` is the index of the snap point to open the bottom sheet to. If >0, the bottom sheet is open. + */ const isOpen = openIndex > -1 const open = React.useCallback( ({index} = {}) => { + // can be set to any index of `snapPoints`, but `0` is the first i.e. "open" setOpenIndex(index || 0) }, [setOpenIndex], diff --git a/src/components/Dialog/types.ts b/src/components/Dialog/types.ts index fe6e87828a..00178926a0 100644 --- a/src/components/Dialog/types.ts +++ b/src/components/Dialog/types.ts @@ -10,7 +10,15 @@ export type DialogContextProps = { close: () => void } -export type DialogControlOpenOptions = {index?: number} +export type DialogControlOpenOptions = { + /** + * NATIVE ONLY + * + * Optional index of the snap point to open the bottom sheet to. Defaults to + * 0, which is the first snap point (i.e. "open"). + */ + index?: number +} export type DialogControlProps = { open: (options?: DialogControlOpenOptions) => void