Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[base] Removes invisible tabbable elements from
TrapFocus
component (…
- Loading branch information
1 parent
f4b3a45
commit f703696
Showing
8 changed files
with
132 additions
and
3 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
docs/data/base/components/trap-focus/ContainedToggleTrappedFocus.js
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,33 @@ | ||
import * as React from 'react'; | ||
import Box from '@mui/material/Box'; | ||
import Stack from '@mui/material/Stack'; | ||
import TrapFocus from '@mui/base/TrapFocus'; | ||
|
||
export default function BasicTrapFocus() { | ||
const [open, setOpen] = React.useState(false); | ||
|
||
return ( | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
alignItems: 'center', | ||
flexDirection: 'column', | ||
}} | ||
> | ||
<TrapFocus open={open} disableRestoreFocus disableAutoFocus> | ||
<Stack> | ||
<Stack alignItems="center"> | ||
<button type="button" onClick={() => setOpen(!open)}> | ||
{open ? 'Close' : 'Open'} | ||
</button> | ||
</Stack> | ||
{open && ( | ||
<label> | ||
First name: <input type="text" /> | ||
</label> | ||
)} | ||
</Stack> | ||
</TrapFocus> | ||
</Box> | ||
); | ||
} |
33 changes: 33 additions & 0 deletions
33
docs/data/base/components/trap-focus/ContainedToggleTrappedFocus.tsx
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,33 @@ | ||
import * as React from 'react'; | ||
import Box from '@mui/material/Box'; | ||
import Stack from '@mui/material/Stack'; | ||
import TrapFocus from '@mui/base/TrapFocus'; | ||
|
||
export default function BasicTrapFocus() { | ||
const [open, setOpen] = React.useState(false); | ||
|
||
return ( | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
alignItems: 'center', | ||
flexDirection: 'column', | ||
}} | ||
> | ||
<TrapFocus open={open} disableRestoreFocus disableAutoFocus> | ||
<Stack> | ||
<Stack alignItems="center"> | ||
<button type="button" onClick={() => setOpen(!open)}> | ||
{open ? 'Close' : 'Open'} | ||
</button> | ||
</Stack> | ||
{open && ( | ||
<label> | ||
First name: <input type="text" /> | ||
</label> | ||
)} | ||
</Stack> | ||
</TrapFocus> | ||
</Box> | ||
); | ||
} |
14 changes: 14 additions & 0 deletions
14
docs/data/base/components/trap-focus/ContainedToggleTrappedFocus.tsx.preview
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,14 @@ | ||
<TrapFocus open={open} disableRestoreFocus disableAutoFocus> | ||
<Stack> | ||
<Stack alignItems="center"> | ||
<button type="button" onClick={() => setOpen(!open)}> | ||
{open ? 'Close' : 'Open'} | ||
</button> | ||
</Stack> | ||
{open && ( | ||
<label> | ||
First name: <input type="text" /> | ||
</label> | ||
)} | ||
</Stack> | ||
</TrapFocus> |
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
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