Skip to content

Commit

Permalink
remove focustrap from loaderoverlay
Browse files Browse the repository at this point in the history
  • Loading branch information
scurker committed Nov 21, 2024
1 parent 51c9362 commit aeaba08
Showing 1 changed file with 16 additions and 25 deletions.
41 changes: 16 additions & 25 deletions packages/react/src/components/LoaderOverlay/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { forwardRef, useEffect } from 'react';
import FocusTrap from 'focus-trap-react';
import classNames from 'classnames';
import Loader from '../Loader';
import AxeLoader from './axe-loader';
import AriaIsolate from '../../utils/aria-isolate';
import useFocusTrap from '../../utils/useFocusTrap';
import useSharedRef from '../../utils/useSharedRef';

export interface LoaderOverlayProps
Expand Down Expand Up @@ -48,33 +48,24 @@ const LoaderOverlay = forwardRef<HTMLDivElement, LoaderOverlayProps>(
}
}, []);

const Wrapper = focusTrap ? FocusTrap : React.Fragment;
const wrapperProps = focusTrap
? {
focusTrapOptions: {
fallbackFocus: '.Loader__overlay'
}
}
: {};
useFocusTrap(overlayRef, {
disabled: !focusTrap
});

return (
<Wrapper {...wrapperProps}>
<div
className={classNames('Loader__overlay', className)}
ref={overlayRef}
tabIndex={-1}
{...other}
>
<div className="Loader__overlay__loader">
<Loader />
<AxeLoader />
</div>
{label ? (
<span className="Loader__overlay__label">{label}</span>
) : null}
{children}
<div
className={classNames('Loader__overlay', className)}
ref={overlayRef}
tabIndex={-1}
{...other}
>
<div className="Loader__overlay__loader">
<Loader />
<AxeLoader />
</div>
</Wrapper>
{label ? <span className="Loader__overlay__label">{label}</span> : null}
{children}
</div>
);
}
);
Expand Down

0 comments on commit aeaba08

Please sign in to comment.