Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Headlamp
Commits
fe02900f
Commit
fe02900f
authored
4 years ago
by
René Dudfield
Browse files
Options
Download
Email Patches
Plain Diff
frontend, a11y: Improve focus handling for various components
parent
858d3a1b
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
frontend/src/components/account/Auth.tsx
+10
-2
frontend/src/components/account/Auth.tsx
frontend/src/components/authchooser/index.tsx
+2
-1
frontend/src/components/authchooser/index.tsx
frontend/src/components/common/Chart.stories/__snapshots__/PercentageCircle.stories.storyshot
+8
-0
....stories/__snapshots__/PercentageCircle.stories.storyshot
frontend/src/components/common/Chart.tsx
+8
-1
frontend/src/components/common/Chart.tsx
frontend/src/components/common/Dialog.tsx
+11
-2
frontend/src/components/common/Dialog.tsx
frontend/src/components/common/Label.stories/__snapshots__/StatusLabel.stories.storyshot
+0
-13
...Label.stories/__snapshots__/StatusLabel.stories.storyshot
frontend/src/components/common/Loader.tsx
+1
-1
frontend/src/components/common/Loader.tsx
frontend/src/components/common/Resource/EditorDialog.tsx
+17
-3
frontend/src/components/common/Resource/EditorDialog.tsx
frontend/src/components/common/Resource/Resource.tsx
+2
-0
frontend/src/components/common/Resource/Resource.tsx
frontend/src/components/common/SectionFilterHeader.tsx
+7
-1
frontend/src/components/common/SectionFilterHeader.tsx
frontend/src/components/common/__snapshots__/Loader.stories.storyshot
+2
-0
.../components/common/__snapshots__/Loader.stories.storyshot
frontend/src/components/oidcauth/OauthPopup.tsx
+3
-1
frontend/src/components/oidcauth/OauthPopup.tsx
with
71 additions
and
25 deletions
+71
-25
frontend/src/components/account/Auth.tsx
+
10
-
2
View file @
fe02900f
...
...
@@ -91,14 +91,22 @@ export function PureAuthToken({
onChangeToken
,
onCloseError
,
}:
PureAuthTokenProps
)
{
const
focusedRef
=
React
.
useCallback
(
node
=>
{
if
(
node
!==
null
)
{
node
.
setAttribute
(
'
tabindex
'
,
'
-1
'
);
node
.
focus
();
}
},
[]);
return
(
<
Box
>
<
ClusterDialog
useCover
disableEscapeKeyDown
disableBackdropClick
>
<
DialogTitle
id
=
"responsive-dialog-title"
>
{
title
}
</
DialogTitle
>
<
DialogTitle
ref
=
{
focusedRef
}
id
=
"responsive-dialog-title"
>
{
title
}
</
DialogTitle
>
<
DialogContent
>
<
DialogContentText
>
Please paste your authentication token.
</
DialogContentText
>
<
TextField
autoFocus
margin
=
"dense"
id
=
"token"
label
=
"ID token"
...
...
This diff is collapsed.
Click to expand it.
frontend/src/components/authchooser/index.tsx
+
2
-
1
View file @
fe02900f
...
...
@@ -219,8 +219,9 @@ export function PureAuthChooser({
onCode
=
{
handleOidcAuth
}
url
=
{
oauthUrl
}
title
=
"Headlamp Cluster Authentication"
button
=
{
ColorButton
as
typeof
Button
}
>
<
ColorButton
>
Sign In
</
ColorButton
>
Sign In
</
OauthPopup
>
</
Box
>
)
:
null
}
...
...
This diff is collapsed.
Click to expand it.
frontend/src/components/common/Chart.stories/__snapshots__/PercentageCircle.stories.storyshot
+
8
-
0
View file @
fe02900f
...
...
@@ -5,6 +5,8 @@ exports[`Storyshots Charts/PercentageCircle No Data 1`] = `
id="root"
>
<div
aria-busy="true"
aria-live="polite"
class="MuiBox-root MuiBox-root"
>
<p
...
...
@@ -13,7 +15,9 @@ exports[`Storyshots Charts/PercentageCircle No Data 1`] = `
CPU usage
</p>
<div
aria-label="Loading"
class="MuiBox-root MuiBox-root makeStyles-loaderContainer"
role="status"
>
<div
class="MuiCircularProgress-root MuiCircularProgress-colorPrimary MuiCircularProgress-indeterminate"
...
...
@@ -44,6 +48,8 @@ exports[`Storyshots Charts/PercentageCircle Percent 50 1`] = `
id="root"
>
<div
aria-busy="false"
aria-live="polite"
class="MuiBox-root MuiBox-root"
>
<p
...
...
@@ -124,6 +130,8 @@ exports[`Storyshots Charts/PercentageCircle Percent 100 1`] = `
id="root"
>
<div
aria-busy="false"
aria-live="polite"
class="MuiBox-root MuiBox-root"
>
<p
...
...
This diff is collapsed.
Click to expand it.
frontend/src/components/common/Chart.tsx
+
8
-
1
View file @
fe02900f
...
...
@@ -101,7 +101,14 @@ export function PercentageCircle(props: PercentageCircleProps) {
}
return
(
<
Box
justifyContent
=
"center"
alignItems
=
"center"
alignContent
=
"center"
mx
=
"auto"
>
<
Box
aria-busy
=
{
isLoading
}
aria-live
=
"polite"
justifyContent
=
"center"
alignItems
=
"center"
alignContent
=
"center"
mx
=
"auto"
>
{
title
&&
<
Typography
className
=
{
classes
.
title
}
>
{
title
}
</
Typography
>
}
{
isLoading
?
(
<
Loader
/>
...
...
This diff is collapsed.
Click to expand it.
frontend/src/components/common/Dialog.tsx
+
11
-
2
View file @
fe02900f
...
...
@@ -21,6 +21,13 @@ export function ConfirmDialog(props: ConfirmDialogProps) {
onConfirm
();
}
const
focusedRef
=
React
.
useCallback
(
node
=>
{
if
(
node
!==
null
)
{
node
.
setAttribute
(
'
tabindex
'
,
'
-1
'
);
node
.
focus
();
}
},
[]);
return
(
<
div
>
<
Dialog
...
...
@@ -29,12 +36,14 @@ export function ConfirmDialog(props: ConfirmDialogProps) {
aria-labelledby
=
"alert-dialog-title"
aria-describedby
=
"alert-dialog-description"
>
<
DialogTitle
id
=
"alert-dialog-title"
>
{
title
}
</
DialogTitle
>
<
DialogTitle
ref
=
{
focusedRef
}
id
=
"alert-dialog-title"
>
{
title
}
</
DialogTitle
>
<
DialogContent
>
<
DialogContentText
id
=
"alert-dialog-description"
>
{
description
}
</
DialogContentText
>
</
DialogContent
>
<
DialogActions
>
<
Button
onClick
=
{
handleClose
}
color
=
"primary"
autoFocus
>
<
Button
onClick
=
{
handleClose
}
color
=
"primary"
>
No
</
Button
>
<
Button
onClick
=
{
onConfirmationClicked
}
color
=
"primary"
>
...
...
This diff is collapsed.
Click to expand it.
frontend/src/components/common/Label.stories/__snapshots__/StatusLabel.stories.storyshot
+
0
-
13
View file @
fe02900f
...
...
@@ -13,19 +13,6 @@ exports[`Storyshots Label/StatusLabel Error 1`] = `
</div>
`;
exports[`Storyshots Label/StatusLabel Status Label 1`] = `
<div
id="root"
>
<span
class="MuiTypography-root makeStyles-statusLabel MuiTypography-body1"
style="background-color: rgb(232, 245, 233); color: rgb(76, 175, 80);"
>
status
</span>
</div>
`;
exports[`Storyshots Label/StatusLabel Success 1`] = `
<div
id="root"
...
...
This diff is collapsed.
Click to expand it.
frontend/src/components/common/Loader.tsx
+
1
-
1
View file @
fe02900f
...
...
@@ -21,7 +21,7 @@ export default function Loader(props: LoaderProps & CircularProgressProps) {
if
(
noContainer
)
return
progress
;
return
(
<
Box
className
=
{
classes
.
loaderContainer
}
py
=
{
3
}
px
=
"auto"
>
<
Box
className
=
{
classes
.
loaderContainer
}
py
=
{
3
}
px
=
"auto"
aria-label
=
"Loading"
role
=
"status"
>
{
progress
}
</
Box
>
);
...
...
This diff is collapsed.
Click to expand it.
frontend/src/components/common/Resource/EditorDialog.tsx
+
17
-
3
View file @
fe02900f
...
...
@@ -206,13 +206,27 @@ export default function EditorDialog(props: EditorDialogProps) {
:
`Edit:
${
item
.
metadata
?.
name
||
'
New Object
'
}
`
;
}
const
focusedRef
=
React
.
useCallback
(
node
=>
{
if
(
node
!==
null
)
{
node
.
setAttribute
(
'
tabindex
'
,
'
-1
'
);
node
.
focus
();
}
},
[]);
return
(
<
Dialog
maxWidth
=
"lg"
scroll
=
"paper"
fullWidth
onBackdropClick
=
{
onClose
}
{
...
other
}
>
<
Dialog
aria-busy
=
{
!
item
}
maxWidth
=
"lg"
scroll
=
"paper"
fullWidth
onBackdropClick
=
{
onClose
}
{
...
other
}
>
{
!
item
?
(
<
Loader
/>
)
:
(
<
React
.
Fragment
>
<
DialogTitle
>
{
dialogTitle
}
</
DialogTitle
>
<
DialogTitle
ref
=
{
focusedRef
}
>
{
dialogTitle
}
</
DialogTitle
>
<
DialogContent
className
=
{
classes
.
dialogContent
}
>
{
isReadOnly
()
?
(
<
OurEditor
/>
...
...
@@ -255,7 +269,7 @@ export default function EditorDialog(props: EditorDialogProps) {
<
div
style
=
{
{
flex
:
'
1 0 0
'
}
}
/>
{
errorLabel
&&
<
Typography
color
=
"error"
>
{
errorLabel
}
</
Typography
>
}
<
div
style
=
{
{
flex
:
'
1 0 0
'
}
}
/>
<
Button
onClick
=
{
onClose
}
color
=
"primary"
autoFocus
>
<
Button
onClick
=
{
onClose
}
color
=
"primary"
>
Close
</
Button
>
{
!
isReadOnly
()
&&
(
...
...
This diff is collapsed.
Click to expand it.
frontend/src/components/common/Resource/Resource.tsx
+
2
-
0
View file @
fe02900f
...
...
@@ -106,6 +106,8 @@ export function MainInfoSection(props: MainInfoSectionProps) {
</
Button
>
)
}
<
SectionBox
aria-busy
=
{
resource
===
null
}
aria-live
=
"polite"
title
=
{
<
SectionHeader
title
=
{
title
||
(
resource
?
resource
.
kind
:
''
)
}
...
...
This diff is collapsed.
Click to expand it.
frontend/src/components/common/SectionFilterHeader.tsx
+
7
-
1
View file @
fe02900f
...
...
@@ -44,6 +44,12 @@ export default function SectionFilterHeader(props: SectionFilterHeaderProps) {
}
});
const
focusedRef
=
React
.
useCallback
(
node
=>
{
if
(
node
!==
null
)
{
node
.
focus
();
}
},
[]);
React
.
useEffect
(
()
=>
{
const
namespace
=
getFilterValueByNameFromURL
(
'
namespace
'
,
location
);
...
...
@@ -95,8 +101,8 @@ export default function SectionFilterHeader(props: SectionFilterHeaderProps) {
InputLabelProps
=
{
{
shrink
:
true
}
}
placeholder
=
"Filter"
value
=
{
filter
.
search
}
autoFocus
onChange
=
{
event
=>
dispatch
(
setSearchFilter
(
event
.
target
.
value
))
}
ref
=
{
focusedRef
}
/>
</
Grid
>
<
Grid
item
>
...
...
This diff is collapsed.
Click to expand it.
frontend/src/components/common/__snapshots__/Loader.stories.storyshot
+
2
-
0
View file @
fe02900f
...
...
@@ -5,7 +5,9 @@ exports[`Storyshots Loader With Container 1`] = `
id="root"
>
<div
aria-label="Loading"
class="MuiBox-root MuiBox-root makeStyles-loaderContainer"
role="status"
>
<div
class="MuiCircularProgress-root MuiCircularProgress-colorPrimary MuiCircularProgress-indeterminate"
...
...
This diff is collapsed.
Click to expand it.
frontend/src/components/oidcauth/OauthPopup.tsx
+
3
-
1
View file @
fe02900f
import
Button
from
'
@material-ui/core/Button
'
;
import
React
,
{
ReactChild
}
from
'
react
'
;
interface
OauthPopupProps
{
...
...
@@ -8,6 +9,7 @@ interface OauthPopupProps {
onClose
?:
()
=>
any
;
onCode
:
(
params
:
any
)
=>
any
;
children
?:
ReactChild
;
button
:
typeof
Button
;
}
const
defaultOauthPopupProps
=
{
...
...
@@ -78,7 +80,7 @@ const OauthPopup: React.FC<OauthPopupProps> = props => {
}
};
return
<
div
onClick
=
{
createPopup
}
>
{
props
.
children
}
</
div
>;
return
<
props
.
button
onClick
=
{
createPopup
}
>
{
props
.
children
}
</
props
.
button
>;
};
export
default
OauthPopup
;
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment