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(a11y): associate labels with inputs #1055

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions ui/src/components/ControlWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import CONTROL_TYPE_MAP, { ComponentTypes } from '../constants/ControlTypeMap';
import { AnyEntity, UtilControlWrapper } from './BaseFormTypes';
import { AcceptableFormValueOrNullish } from '../types/components/shareableTypes';

const CustomElement = styled.div``;

const ControlGroupWrapper = styled(ControlGroup).attrs((props: { dataName: string }) => ({
'data-name': props.dataName,
}))`
Expand Down Expand Up @@ -110,13 +108,12 @@ class ControlWrapper extends React.PureComponent<ControlWrapperProps> {
<ControlGroupWrapper
help={helpText}
error={this.props.error}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore property should be data-name, but is mapped in obj ControlGroupWrapper
// @ts-expect-error property should be data-name, but is mapped in obj ControlGroupWrapper
dataName={this?.props?.entity.field}
labelWidth={240}
{...this?.props?.entity}
>
<CustomElement>{rowView}</CustomElement>
{rowView}
</ControlGroupWrapper>
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const WaitSpinnerWrapper = styled(WaitSpinner)`
`;

export interface MultiInputComponentProps {
id?: string;
handleChange: (field: string, data: string) => void;
field: string;
controlOptions: {
Expand All @@ -40,6 +41,7 @@ export interface MultiInputComponentProps {

function MultiInputComponent(props: MultiInputComponentProps) {
const {
id,
field,
disabled = false,
error = false,
Expand Down Expand Up @@ -135,6 +137,7 @@ function MultiInputComponent(props: MultiInputComponentProps) {
return (
<>
<MultiSelectWrapper
inputId={id}
values={valueList}
error={error}
name={field}
Expand Down
2 changes: 2 additions & 0 deletions ui/src/components/RadioComponent/RadioComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const RadioBarOption = styled(RadioBar.Option)`
`;

interface RadioComponentProps {
id?: string;
value: string;
handleChange: (field: string, value: string) => void;
field: string;
Expand All @@ -31,6 +32,7 @@ class RadioComponent extends Component<RadioComponentProps> {
render() {
return (
<RadioBarWrapper
id={this.props.id}
inline
onChange={this.handleChange}
value={this.props.value}
Expand Down
2 changes: 2 additions & 0 deletions ui/src/components/SingleInputComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ interface FormItem {
}

interface SingleInputComponentProps {
id?: string;
disabled?: boolean;
value: string;
error?: boolean;
Expand Down Expand Up @@ -181,6 +182,7 @@ function SingleInputComponent(props: SingleInputComponentProps) {
) : (
<>
<SelectWrapper
inputId={props.id}
className="dropdownBox"
data-test-loading={loading}
value={props.value}
Expand Down
6 changes: 4 additions & 2 deletions ui/src/components/TextAreaComponent/TextAreaComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const TextWrapper = styled(TextArea)`
width: 320px !important;
`;

interface TextAreadComponentProps {
interface TextAreaComponentProps {
id?: string;
value: string | number;
handleChange: (field: string, value: string) => void;
field: string;
Expand All @@ -15,13 +16,14 @@ interface TextAreadComponentProps {
disabled?: boolean;
}

function TextAreaComponent(props: TextAreadComponentProps) {
function TextAreaComponent(props: TextAreaComponentProps) {
const handleChange = (e: unknown, { value }: { value: string }) => {
props.handleChange(props.field, value);
};

return (
<TextWrapper
inputId={props.id}
inline
canClear
error={props.error}
Expand Down
2 changes: 2 additions & 0 deletions ui/src/components/TextComponent/TextComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface TextComponentProps {
error?: boolean;
encrypted?: boolean;
disabled?: boolean;
id?: string;
}

class TextComponent extends Component<TextComponentProps> {
Expand All @@ -24,6 +25,7 @@ class TextComponent extends Component<TextComponentProps> {
render() {
return (
<TextWrapper
inputId={this.props.id}
inline
error={this.props.error}
className={this.props.field}
Expand Down
Loading