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

feat: add overlayEnable option in drawer layout #11652

Open
wants to merge 1 commit into
base: main
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/react-native-drawer-layout/src/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ export type DrawerProps = {
*/
drawerStyle?: StyleProp<ViewStyle>;

/**
* Whether the overlay is enabled.
* If false, interaction is possible with the drawer content while drawer is open.
* Defaults to `true`.
*/
overlayEnabled?: boolean;

/**
* Style object for the drawer overlay.
*/
Expand Down
2 changes: 2 additions & 0 deletions packages/react-native-drawer-layout/src/views/Drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export function Drawer({
keyboardDismissMode = 'on-drag',
hideStatusBarOnOpen = false,
statusBarAnimation = 'slide',
overlayEnabled = true,
style,
...rest
}: Props) {
Expand Down Expand Up @@ -107,6 +108,7 @@ export function Drawer({
keyboardDismissMode={keyboardDismissMode}
hideStatusBarOnOpen={hideStatusBarOnOpen}
statusBarAnimation={statusBarAnimation}
overlayEnabled={overlayEnabled}
/>
</GestureHandlerRootView>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ export class Drawer extends React.Component<Props> {
children,
gestureHandlerProps,
overlayAccessibilityLabel,
overlayEnabled,
} = this.props;

const isOpen = drawerType === 'permanent' ? true : open;
Expand Down Expand Up @@ -596,8 +597,8 @@ export class Drawer extends React.Component<Props> {
{children}
</View>
{
// Disable overlay if sidebar is permanent
drawerType === 'permanent' ? null : (
// Disable overlay if sidebar is permanent or not overlayEnabled
drawerType === 'permanent' || !overlayEnabled ? null : (
<Overlay
progress={progress}
onPress={() => this.toggleDrawer(false)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export function Drawer({
onTransitionStart,
onTransitionEnd,
open,
overlayEnabled,
overlayStyle,
overlayAccessibilityLabel,
statusBarAnimation,
Expand Down Expand Up @@ -395,7 +396,7 @@ export function Drawer({
>
{children}
</View>
{drawerType !== 'permanent' ? (
{drawerType !== 'permanent' && overlayEnabled ? (
<Overlay
progress={progress}
onPress={() => toggleDrawer(false)}
Expand Down