Skip to content

Commit

Permalink
chore: fix app wide accessibility issues
Browse files Browse the repository at this point in the history
- disable link in logo for small screen (reason: same adjacent link URL)
- removed or changed title attribute so it's not identical to text content
- TablePagination aria-label
- remove uneccessary label for browse images button (InstanceCreateDetailsForm)
- add text to hidden inputs
- Resolve multiple label for the same form control
- Remove uneccessary element titles or adjust for better meaning
- Adjusted heading elements to not skip heirarchical order
- Added aria-label for Select components that's missing labels
- Added aria-label for Button components that's missing text (e.g. icon buttons)

Signed-off-by: Mason Hu <[email protected]>
  • Loading branch information
mas-who authored and edlerd committed Feb 14, 2024
1 parent 2496a2b commit 6e067b3
Show file tree
Hide file tree
Showing 40 changed files with 97 additions and 79 deletions.
2 changes: 1 addition & 1 deletion src/components/RenameHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const RenameHeader: FC<Props> = ({
<li
className="p-breadcrumbs__item name u-truncate"
onClick={enableRename}
title={name}
title={`Rename ${name}`}
>
<Tooltip
message={!canRename && renameDisabledReason}
Expand Down
14 changes: 6 additions & 8 deletions src/components/SnapshotScheduleInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@ import { Input, RadioInput, Select } from "@canonical/react-components";

const snapshotOptions = [
{
label: "minute",
label: "Every minute",
value: "* * * * *",
},
{
label: "hour",
label: "Hourly",
value: "@hourly",
},
{
label: "day",
label: "Daily",
value: "@daily",
},
{
label: "week",
label: "Weekly",
value: "@weekly",
},
{
label: "month",
label: "Monthly",
value: "@monthly",
},
{
label: "year",
label: "Yearly",
value: "@yearly",
},
];
Expand Down Expand Up @@ -60,7 +60,6 @@ const SnapshotScheduleInput: FC<Props> = ({ value, setValue }) => {
<Input
id="snapshots_schedule"
name="snapshots_schedule"
label="Cron expression"
placeholder="Enter cron expression"
help="<minute> <hour> <dom> <month> <dow>, a comma-separated list of schedule aliases (@hourly, @daily, @midnight, @weekly, @monthly, @annually, @yearly), or empty to disable automatic snapshots (the default)"
type="text"
Expand All @@ -71,7 +70,6 @@ const SnapshotScheduleInput: FC<Props> = ({ value, setValue }) => {
<Select
id="snapshots_schedule"
name="snapshots_schedule"
label="Every"
value={value}
onChange={(e) => setValue(e.target.value)}
options={snapshotOptions}
Expand Down
2 changes: 1 addition & 1 deletion src/components/forms/DiskDeviceForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const DiskDeviceForm: FC<Props> = ({ formik, project }) => {
>
<ScrollableForm>
{/* hidden submit to enable enter key in inputs */}
<Input type="submit" hidden />
<Input type="submit" hidden value="Hidden input" />
<DiskDeviceFormRoot
formik={formik}
project={project}
Expand Down
29 changes: 21 additions & 8 deletions src/components/forms/DiskDeviceRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,27 @@ export const getDiskDeviceRow = ({
return getConfigurationRowBase({
className: classnames("no-border-top", className),
configuration: id ? (
<Label
forId={id}
className={classnames({
"u-text--muted": isDeactivated,
})}
>
{label}
</Label>
!readOnly && overrideValue ? (
<Label
forId={id}
className={classnames({
"u-text--muted": isDeactivated,
})}
>
{label}
</Label>
) : (
<p
className={classnames(
"p-form__label u-no-margin--bottom u-no-padding--top",
{
"u-text--muted": isDeactivated,
},
)}
>
{label}
</p>
)
) : (
<div
className={classnames({
Expand Down
2 changes: 1 addition & 1 deletion src/components/forms/YamlForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const YamlForm: FC<Props> = ({
<Editor
defaultValue={yaml}
language="yaml"
theme="vs-dark"
theme="hc-black"
onChange={(value) => value && setYaml && setYaml(value)}
options={{
fontSize: 18,
Expand Down
1 change: 1 addition & 0 deletions src/pages/cluster/ClusterList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ const ClusterList: FC = () => {
id="pagination"
itemName="cluster member"
className="u-no-margin--top"
aria-label="Table pagination control"
>
<MainTable
id="cluster-table"
Expand Down
1 change: 1 addition & 0 deletions src/pages/images/ImageList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ const ImageList: FC = () => {
id="pagination"
itemName="image"
className="u-no-margin--top"
aria-label="Table pagination control"
description={
selectedNames.length > 0 && (
<SelectedTableNotification
Expand Down
1 change: 1 addition & 0 deletions src/pages/instances/CreateInstance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ const CreateInstance: FC = () => {
<Notification
severity="caution"
title="Before you edit the YAML"
titleElement="h2"
>
Changes will be discarded, when switching back to the guided
forms.
Expand Down
2 changes: 1 addition & 1 deletion src/pages/instances/InstanceIps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const InstanceIps: FC<Props> = ({ instance, family }) => {
<div
key={item.address}
className="ip u-truncate"
title={`${item.address} (${item.iface})`}
title={`IP ${item.address} (${item.iface})`}
>
{item.address} ({item.iface})
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/pages/instances/InstanceList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ const InstanceList: FC = () => {
columns: [
{
content: (
<div className="u-truncate" title={instance.name}>
<div className="u-truncate" title={`Instance ${instance.name}`}>
<InstanceLink instance={instance} />
</div>
),
Expand Down Expand Up @@ -555,6 +555,7 @@ const InstanceList: FC = () => {
id="pagination"
itemName="instance"
className="u-no-margin--top"
aria-label="Table pagination control"
description={
selectedNames.length > 0 && (
<SelectedTableNotification
Expand Down
2 changes: 1 addition & 1 deletion src/pages/instances/InstanceOverviewNetworks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const InstanceOverviewNetworks: FC<Props> = ({ instance, onFailure }) => {
content: (
<Link
to={`/ui/project/${instance.project}/networks/detail/${network.name}`}
title={network.name}
title={`Network ${network.name}`}
>
{network.name}
</Link>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/instances/InstanceOverviewProfiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const InstanceOverviewProfiles: FC<Props> = ({ instance, onFailure }) => {
content: (
<Link
to={`/ui/project/${instance.project}/profiles/detail/${profile}`}
title={profile}
title={`Profile ${profile}`}
>
{profile}
</Link>
Expand All @@ -60,7 +60,7 @@ const InstanceOverviewProfiles: FC<Props> = ({ instance, onFailure }) => {
{
content: description,
role: "rowheader",
title: description,
title: `Description ${description}`,
"aria-label": "Description",
},
],
Expand Down
3 changes: 2 additions & 1 deletion src/pages/instances/InstanceSnapshots.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const InstanceSnapshots = (props: Props) => {
{
content: (
<>
<div className="u-truncate" title={snapshot.name}>
<div className="u-truncate" title={`Snapshot ${snapshot.name}`}>
<ItemName item={snapshot} />
</div>
{isSmallScreen && (
Expand Down Expand Up @@ -253,6 +253,7 @@ const InstanceSnapshots = (props: Props) => {
id="pagination"
itemName="snapshot"
className="u-no-margin--top"
aria-label="Table pagination control"
description={
selectedNames.length > 0 && (
<SelectedTableNotification
Expand Down
2 changes: 1 addition & 1 deletion src/pages/instances/TerminalPayloadForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const TerminalPayloadForm: FC<Props> = ({ payload, close, reconnect }) => {
>
<Form onSubmit={formik.handleSubmit}>
{/* hidden submit to enable enter key in inputs */}
<Input type="submit" hidden />
<Input type="submit" hidden value="Hidden input" />
<div className="content-wrapper">
<Input
id="command"
Expand Down
9 changes: 3 additions & 6 deletions src/pages/instances/forms/InstanceCreateDetailsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,9 @@ const InstanceCreateDetailsForm: FC<Props> = ({
</Row>
<Row>
<Col size={12}>
<label className="p-form__label" htmlFor="base-image">
Base Image*
</label>
<p className="p-form__label">Base Image*</p>
<div className="p-form__control u-clearfix base-image">
{formik.values.image && (
{formik.values.image ? (
<>
<span className="u-text--muted u-truncate u-sv3 image-name">
{figureBaseImageName()}
Expand All @@ -122,8 +120,7 @@ const InstanceCreateDetailsForm: FC<Props> = ({
<Icon name="close" />
</Button>
</>
)}
{!formik.values.image && (
) : (
<>
<SelectImageBtn onSelect={onSelectImage} />
<UseCustomIsoBtn onSelect={onSelectImage} />
Expand Down
2 changes: 1 addition & 1 deletion src/pages/networks/actions/DeleteNetworkBtn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const DeleteNetworkBtn: FC<Props> = ({ network, project }) => {
? "Can not delete, network is not managed"
: isUsed
? "Can not delete, network is currently in use"
: "Delete network"
: ""
}
confirmationModalProps={{
title: "Confirm delete",
Expand Down
8 changes: 6 additions & 2 deletions src/pages/networks/forms/NetworkForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const NetworkForm: FC<Props> = ({
return (
<Form className="form network-form" onSubmit={formik.handleSubmit}>
{/* hidden submit to enable enter key in inputs */}
<Input type="submit" hidden />
<Input type="submit" hidden value="Hidden input" />
<NetworkFormMenu
active={section}
setActive={setSection}
Expand All @@ -147,7 +147,11 @@ const NetworkForm: FC<Props> = ({
setYaml={(yaml) => void formik.setFieldValue("yaml", yaml)}
readOnly={formik.values.readOnly}
>
<Notification severity="caution" title="Before you edit the YAML">
<Notification
severity="caution"
title="Before you edit the YAML"
titleElement="h2"
>
Changes will be discarded, when switching back to the guided
forms.
</Notification>
Expand Down
8 changes: 6 additions & 2 deletions src/pages/networks/forms/NetworkForwardForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,14 @@ const NetworkForwardForm: FC<Props> = ({
<Col size={12}>
<ScrollableForm>
{/* hidden submit to enable enter key in inputs */}
<Input type="submit" hidden />
<Input type="submit" hidden value="Hidden input" />
<Row className="p-form__group p-form-validation">
<NotificationRow />
<Notification severity="information" title="Network information">
<Notification
severity="information"
title="Network information"
titleElement="h2"
>
Name: {network?.name}
<br />
{network?.config["ipv4.address"] && (
Expand Down
15 changes: 6 additions & 9 deletions src/pages/networks/forms/NetworkForwardFormPorts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const NetworkForwardFormPorts: FC<Props> = ({ formik, network }) => {
Target port
</Label>
</th>
<th />
<th className="u-off-screen">Actions</th>
</tr>
</thead>
<tbody>
Expand All @@ -75,8 +75,7 @@ const NetworkForwardFormPorts: FC<Props> = ({ formik, network }) => {
{...formik.getFieldProps(`ports.${index}.listenPort`)}
id={`ports.${index}.listenPort`}
type="text"
label="Listen port"
labelClassName="u-off-screen"
aria-label={`Port ${index} listen port`}
placeholder="Port number(s)"
help={
index === formik.values.ports.length - 1 && (
Expand All @@ -98,17 +97,15 @@ const NetworkForwardFormPorts: FC<Props> = ({ formik, network }) => {
{ label: "TCP", value: "tcp" },
{ label: "UDP", value: "udp" },
]}
label="Protocol"
labelClassName="u-off-screen"
aria-label={`Port ${index} protocol`}
/>
</td>
<td className="target-address">
<Input
{...formik.getFieldProps(`ports.${index}.targetAddress`)}
id={`ports.${index}.targetAddress`}
type="text"
label="Target address"
labelClassName="u-off-screen"
aria-label={`Port ${index} target address`}
placeholder="Enter IP address"
help={
index === formik.values.ports.length - 1 && (
Expand All @@ -129,8 +126,7 @@ const NetworkForwardFormPorts: FC<Props> = ({ formik, network }) => {
{...formik.getFieldProps(`ports.${index}.targetPort`)}
id={`ports.${index}.targetPort`}
type="text"
label="Target port"
labelClassName="u-off-screen"
aria-label={`Port ${index} target port`}
placeholder="Port number(s)"
help={
index === formik.values.ports.length - 1 &&
Expand All @@ -154,6 +150,7 @@ const NetworkForwardFormPorts: FC<Props> = ({ formik, network }) => {
hasIcon
className="u-no-margin--bottom"
type="button"
aria-label={`Delete port ${index}`}
>
<Icon name="delete" />
</Button>
Expand Down
1 change: 1 addition & 0 deletions src/pages/profiles/CreateProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ const CreateProfile: FC = () => {
<Notification
severity="caution"
title="Before you edit the YAML"
titleElement="h2"
>
Changes will be discarded, when switching back to the guided
forms.
Expand Down
1 change: 1 addition & 0 deletions src/pages/profiles/EditProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ const EditProfile: FC<Props> = ({ profile, featuresProfiles }) => {
<Notification
severity="caution"
title="Before you edit the YAML"
titleElement="h2"
>
Changes will be discarded, when switching back to the guided
forms.
Expand Down
8 changes: 6 additions & 2 deletions src/pages/profiles/ProfileList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const ProfileList: FC = () => {
columns: [
{
content: (
<div className="u-truncate" title={profile.name}>
<div className="u-truncate" title={`Profile ${profile.name}`}>
<ProfileLink
profile={{ name: profile.name, project: projectName }}
/>
Expand All @@ -126,7 +126,10 @@ const ProfileList: FC = () => {
},
{
content: (
<div className="profile-description" title={profile.description}>
<div
className="profile-description"
title={`Description ${profile.description}`}
>
{profile.description}
</div>
),
Expand Down Expand Up @@ -227,6 +230,7 @@ const ProfileList: FC = () => {
data={sortedRows}
itemName="profile"
className="u-no-margin--top"
aria-label="Table pagination control"
>
<MainTable
id="profile-table"
Expand Down
2 changes: 1 addition & 1 deletion src/pages/profiles/ProfileNetworkList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const ProfileNetworkList: FC<Props> = ({ profile }) => {
<div
key={device.network}
className="u-truncate list-item"
title={device.network}
title={`Network ${device.network}`}
>
{device.network}
</div>
Expand Down
Loading

0 comments on commit 6e067b3

Please sign in to comment.