Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/2901 improve devtools a11y #2947

Merged
merged 3 commits into from Nov 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 21 additions & 5 deletions src/devtools/devtools.tsx
Expand Up @@ -55,7 +55,7 @@ interface DevtoolsOptions {
/**
* Use this to render the devtools inside a different type of container element for a11y purposes.
* Any string which corresponds to a valid intrinsic JSX element is allowed.
* Defaults to 'footer'.
* Defaults to 'aside'.
*/
containerElement?: string | any
}
Expand Down Expand Up @@ -91,7 +91,7 @@ export function ReactQueryDevtools({
closeButtonProps = {},
toggleButtonProps = {},
position = 'bottom-left',
containerElement: Container = 'footer',
containerElement: Container = 'aside',
}: DevtoolsOptions): React.ReactElement | null {
const rootRef = React.useRef<HTMLDivElement>(null)
const panelRef = React.useRef<HTMLDivElement>(null)
Expand Down Expand Up @@ -221,7 +221,11 @@ export function ReactQueryDevtools({
if (!isMounted()) return null

return (
<Container ref={rootRef} className="ReactQueryDevtools">
<Container
ref={rootRef}
className="ReactQueryDevtools"
aria-label="React Query Devtools"
>
<ThemeProvider theme={theme}>
<ReactQueryDevtoolsPanel
ref={panelRef as any}
Expand Down Expand Up @@ -265,6 +269,9 @@ export function ReactQueryDevtools({
<Button
type="button"
aria-label="Close React Query Devtools"
aria-controls="ReactQueryDevtoolsPanel"
aria-haspopup="true"
aria-expanded="true"
{...(otherCloseButtonProps as unknown)}
onClick={e => {
setIsOpen(false)
Expand Down Expand Up @@ -302,6 +309,9 @@ export function ReactQueryDevtools({
type="button"
{...otherToggleButtonProps}
aria-label="Open React Query Devtools"
aria-controls="ReactQueryDevtoolsPanel"
aria-haspopup="true"
aria-expanded="false"
onClick={e => {
setIsOpen(true)
onToggleClick && onToggleClick(e)
Expand Down Expand Up @@ -449,7 +459,13 @@ export const ReactQueryDevtoolsPanel = React.forwardRef<

return (
<ThemeProvider theme={theme}>
<Panel ref={ref} className="ReactQueryDevtoolsPanel" {...panelProps}>
<Panel
ref={ref}
className="ReactQueryDevtoolsPanel"
aria-label="React Query Devtools Panel"
id="ReactQueryDevtoolsPanel"
{...panelProps}
>
<style
dangerouslySetInnerHTML={{
__html: `
Expand Down Expand Up @@ -494,7 +510,7 @@ export const ReactQueryDevtoolsPanel = React.forwardRef<
maxHeight: '100%',
overflow: 'auto',
borderRight: `1px solid ${theme.grayAlt}`,
display: 'flex',
display: isOpen ? 'flex' : 'none',
flexDirection: 'column',
}}
>
Expand Down