diff --git a/src/UI.tsx b/src/UI.tsx index e4356d9..5ec08d6 100644 --- a/src/UI.tsx +++ b/src/UI.tsx @@ -24,6 +24,7 @@ export const FocusOn = React.forwardRef( sideCar, className, shouldIgnore, + preventScrollOnFocus, style, as, ...rest @@ -58,6 +59,7 @@ export const FocusOn = React.forwardRef( className={className} whiteList={shouldIgnore} lockProps={appliedLockProps} + focusOptions={preventScrollOnFocus ? { preventScroll: true } : undefined} as={RemoveScroll} > {children} diff --git a/src/types.ts b/src/types.ts index 4ab5000..1924ba3 100644 --- a/src/types.ts +++ b/src/types.ts @@ -80,7 +80,11 @@ export interface ReactFocusOnProps extends CommonProps { * @default true */ returnFocus?: ComponentProps['returnFocus'] | undefined; - + /** + * [focus-lock] prevents scroll on focus via focusOptions + * @default false + */ + preventScrollOnFocus?: boolean | undefined; /** * [focus-lock] allows "ignoring" focus on some elements * @see {@link https://github.com/theKashey/react-focus-lock#api}