feat: animated closeAll & onBeforeClose#19
Merged
Conversation
…ceptor closeAll() closes all sheets in a group from top to bottom with staggered animation delays (configurable via `stagger` option), similar to popToRoot in React Navigation. onBeforeClose allows sheets to intercept and prevent closing by registering a callback via useOnBeforeClose hook. The callback can return false (sync or async) to cancel the close. All close paths (backdrop tap, swipe dismiss, programmatic close, closeAll) respect the interceptor. A forceClose() method is provided on useBottomSheetContext to bypass the interceptor when needed. https://claude.ai/code/session_014M8zrTTx3wtbNXKCHmJNaw
…is active When useOnBeforeClose is registered, the sheet now sets preventDismiss in the store. All adapters read this flag and disable native dismiss gestures: - GorhomSheetAdapter: disables enablePanDownToClose - ReactNativeModalAdapter: disables swipeDirection and onSwipeComplete - ActionsSheetAdapter: disables gestureEnabled, closeOnTouchBackdrop, closeOnPressBack This ensures the interceptor actually prevents closing at the gesture level, not just the programmatic level. https://claude.ai/code/session_014M8zrTTx3wtbNXKCHmJNaw
Mirrors the existing cleanup pattern for sheetRefs and animatedIndexes. Ensures the global onBeforeClose map doesn't leak stale callbacks when sheets are removed via clearGroup, clearAll, or normal close flows. https://claude.ai/code/session_014M8zrTTx3wtbNXKCHmJNaw
Replace all `void requestClose(...)` patterns with plain calls. Simplify handleDismiss interceptor to reuse requestClose directly. Add proper dependency array to useOnBeforeClose useEffect. https://claude.ai/code/session_014M8zrTTx3wtbNXKCHmJNaw
- New docs/close-interception.md: useOnBeforeClose, forceClose, closeAll cascade behavior, async interceptors, adapter support - hooks.md: add useOnBeforeClose section, closeAll to manager/control, forceClose to context returns - types.md: add OnBeforeCloseCallback, CloseAllOptions, preventDismiss and keepMounted to BottomSheetState, update return type interfaces - intro.md: add close interception and cascading close to features list - sidebars.ts: add close-interception page https://claude.ai/code/session_014M8zrTTx3wtbNXKCHmJNaw
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.