Skip to content

Commit

Permalink
Merge pull request #63 from constancecchen/master
Browse files Browse the repository at this point in the history
feat: Add explicit `focusOptions` support for `ReactFocusLock`
  • Loading branch information
theKashey authored Nov 13, 2022
2 parents a2f4fd8 + 6587e9d commit 7a2900f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/UI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const FocusOn = React.forwardRef<HTMLElement, ReactFocusOnSideProps>(
sideCar,
className,
shouldIgnore,
preventScrollOnFocus,
style,
as,
...rest
Expand Down Expand Up @@ -58,6 +59,7 @@ export const FocusOn = React.forwardRef<HTMLElement, ReactFocusOnSideProps>(
className={className}
whiteList={shouldIgnore}
lockProps={appliedLockProps}
focusOptions={preventScrollOnFocus ? { preventScroll: true } : undefined}
as={RemoveScroll}
>
{children}
Expand Down
6 changes: 5 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ export interface ReactFocusOnProps extends CommonProps {
* @default true
*/
returnFocus?: ComponentProps<typeof ReactFocusLock>['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}
Expand Down

0 comments on commit 7a2900f

Please sign in to comment.