-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: panel: fix panel animation while closing (#414)
- Loading branch information
1 parent
651d4fd
commit 7e12a20
Showing
3 changed files
with
108 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,27 @@ | ||
import React from 'react'; | ||
|
||
import React, { FC } from 'react'; | ||
import { useFocusTrap } from './hooks/useFocusTrap'; | ||
import { OcBaseProps } from '../../components/OcBase'; | ||
|
||
interface Pros { | ||
children: React.ReactElement; | ||
interface FocusTrapProps extends OcBaseProps<HTMLDivElement> { | ||
trap: boolean; | ||
} | ||
|
||
export const FocusTrap = ({ children, trap = true }: Pros): JSX.Element => { | ||
export const FocusTrap: FC<FocusTrapProps> = ({ | ||
trap = true, | ||
children, | ||
classNames, | ||
'data-test-id': dataTestId, | ||
...rest | ||
}) => { | ||
const focusRef = useFocusTrap(trap); | ||
if (!trap) return children; | ||
return <div ref={focusRef}>{children}</div>; | ||
return ( | ||
<div | ||
ref={focusRef} | ||
className={classNames} | ||
data-test-id={dataTestId} | ||
{...rest} | ||
> | ||
{children} | ||
</div> | ||
); | ||
}; |