Skip to content

Commit

Permalink
feat: onClickOutside event
Browse files Browse the repository at this point in the history
  • Loading branch information
theKashey committed Nov 7, 2018
1 parent 82cc4bb commit ed4d62b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Now you could __focus on__ a single task.
- `[autoFocus]` - enables of disabled auto focus management (see [react-focus-lock documentation])
- `[onActivation]` - on activation callback
- `[onDeactivation]` - on deactivation callback
- `[onClickOutside]` - on click outside of "focus" area. (actually on any event "outside")

## Additional API
### Exposed from React-Focus-Lock
Expand Down
4 changes: 3 additions & 1 deletion src/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface ReactFocusOnProps {
autoFocus?: boolean;
onActivation?: (node: HTMLElement) => void;
onDeactivation?: () => void;
onClickOutside?: () => void;
}

export class ReactFocusOn extends Component<ReactFocusOnProps> {
Expand All @@ -31,10 +32,11 @@ export class ReactFocusOn extends Component<ReactFocusOnProps> {
};

render() {
const {children, autoFocus, enabled = true} = this.props;
const {children, autoFocus, onClickOutside, enabled = true} = this.props;
return (
<ScrollLocky
enabled={enabled}
onEscape={onClickOutside}
>
<ReactFocusLock
autoFocus={autoFocus}
Expand Down

0 comments on commit ed4d62b

Please sign in to comment.