Skip to content

Commit fa5fe87

Browse files
author
Nico Arehart
committed
feat: expose whitelist prop
1 parent ced053e commit fa5fe87

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import {FocusOn} from 'react-focus-on';
5555
---
5656
- `[autoFocus=true]` - enables or disables `auto focus` management (see [react-focus-lock documentation](https://github.com/theKashey/react-focus-lock))
5757
- `[returnFocus=true]` - enables or disables `return focus` on lock deactivation (see [react-focus-lock documentation](https://github.com/theKashey/react-focus-lock))
58+
- `[whiteList=fn]` - you could whitelist locations FocusLock should carry about. Everything outside it will ignore. For example - any modals (see [react-focus-lock documentation](https://github.com/theKashey/react-focus-lock))
5859
---
5960
- `[gapMode]` - the way removed ScrollBar would be _compensated_ - margin(default), or padding. See [scroll-locky documentation](https://github.com/theKashey/react-scroll-locky#gap-modes) to find the one you need.
6061
- `[noIsolation]` - disables aria-hidden isolation

src/UI.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const FocusOn = React.forwardRef<HTMLElement, ReactFocusOnSideProps>(
2323
allowPinchZoom,
2424
sideCar,
2525
className,
26+
whiteList,
2627
...rest
2728
} = props;
2829

@@ -43,6 +44,7 @@ export const FocusOn = React.forwardRef<HTMLElement, ReactFocusOnSideProps>(
4344
onDeactivation={onDeactivation}
4445
className={className}
4546
as={RemoveScroll}
47+
whiteList={whiteList}
4648
lockProps={{
4749
...restProps,
4850
sideCar,

src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ export interface ReactFocusOnProps extends CommonProps {
3434

3535
className?: string;
3636
children: React.ReactNode;
37+
38+
whiteList?: (activeElement: HTMLElement) => boolean;
3739
}
3840

3941
export interface ReactFocusOnSideProps extends ReactFocusOnProps {

0 commit comments

Comments
 (0)