-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: failing test due to limited jest support for focus-trap-react
- Loading branch information
Showing
4 changed files
with
60 additions
and
34 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import FocusTrap from "focus-trap-react"; | ||
import { App } from "./App"; | ||
|
||
export const FocusTrapWrapper: React.FC = () => { | ||
const [activeTrap, setActiveTrap] = useState(false); | ||
|
||
useEffect(() => { | ||
setActiveTrap(true); | ||
}, []); | ||
|
||
const handleSetActiveTrap = (active: boolean) => { | ||
setActiveTrap(active); | ||
} | ||
Check warning on line 14 in src/components/focus-trap-wrapper.tsx GitHub Actions / Build and Run Jest Tests
Check warning on line 14 in src/components/focus-trap-wrapper.tsx GitHub Actions / Build and Run Jest Tests
Check warning on line 14 in src/components/focus-trap-wrapper.tsx GitHub Actions / S3 Deploy
|
||
|
||
return ( | ||
<FocusTrap | ||
active={activeTrap} | ||
focusTrapOptions={{ | ||
allowOutsideClick: true, | ||
escapeDeactivates: true, | ||
onDeactivate: () => setActiveTrap(false), | ||
onActivate: () => setActiveTrap(true), | ||
}} | ||
> | ||
<App activeTrap={activeTrap} handleSetActiveTrap={handleSetActiveTrap}/> | ||
</FocusTrap> | ||
); | ||
}; | ||
|
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,12 +1,12 @@ | ||
import React from "react"; | ||
import { createRoot } from "react-dom/client"; | ||
import { App } from "./components/App"; | ||
import { FocusTrapWrapper } from "./components/focus-trap-wrapper"; | ||
|
||
import "./index.scss"; | ||
|
||
const container = document.getElementById("app"); | ||
if (container) { | ||
const root = createRoot(container); | ||
|
||
root.render(<App />); | ||
root.render(<FocusTrapWrapper />); | ||
} |