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

a11y: add ariaLabel props to EditableField and TextFields #2259

Merged
merged 8 commits into from
Mar 12, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ const ObjectArray: React.FunctionComponent<ArrayFieldTemplateProps> = props => {
}
: {}),
}}
ariaLabel={formatMessage('Object')}
a-b-r-o-w-n marked this conversation as resolved.
Show resolved Hide resolved
data-testid="object-array-text-input"
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const StringArray: React.FunctionComponent<ArrayFieldTemplateProps> = props => {
}}
styles={{ root: { width: '100%' } }}
data-testid="string-array-text-input"
ariaLabel={formatMessage('Value')}
a-b-r-o-w-n marked this conversation as resolved.
Show resolved Hide resolved
/>
<IconButton
disabled={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ export const AssignmentsField: React.FC<BFDFieldProps> = props => {
onChange={handleNewassignmentEdit('property')}
placeholder={formatMessage('Property (named location to store information).')}
autoComplete="off"
ariaLabel={formatMessage('Property')}
/>
</div>
<div css={assignmentItemValue}>
Expand All @@ -229,6 +230,7 @@ export const AssignmentsField: React.FC<BFDFieldProps> = props => {
iconName: 'ReturnKey',
style: { color: SharedColors.cyanBlue10, opacity: 0.6 },
}}
ariaLabel={formatMessage('Value')}
/>
</div>
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const ObjectItem = ({
root: { margin: '7px 0 7px 0' },
}}
errorMessage={errorMessage}
ariaLabel={formatMessage('Key')}
/>
</div>
<div css={customObjectFieldItem}>
Expand All @@ -71,6 +72,7 @@ const ObjectItem = ({
styles={{
root: { margin: '7px 0 7px 0' },
}}
ariaLabel={formatMessage('Value')}
/>
</div>
<IconButton
Expand Down Expand Up @@ -164,6 +166,7 @@ export const CustomObjectField: React.FC<FieldProps> = props => {
styles={{
root: { margin: '7px 0 7px 0' },
}}
ariaLabel={formatMessage('Key')}
/>
</div>
<div css={customObjectFieldItem}>
Expand All @@ -180,6 +183,7 @@ export const CustomObjectField: React.FC<FieldProps> = props => {
styles={{
root: { margin: '7px 0 7px 0' },
}}
ariaLabel={formatMessage('Value')}
/>
</div>
<IconButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ interface EditableFieldProps extends ITextFieldProps {
placeholder?: string;
fontSize?: string;
options?: any;
ariaLabel?: string;
}

export const EditableField: React.FC<EditableFieldProps> = props => {
const { styles = {}, placeholder, fontSize, onChange, onBlur, value, options = {}, ...rest } = props;
const { styles = {}, placeholder, fontSize, onChange, onBlur, value, ariaLabel, options = {}, ...rest } = props;
const { transparentBorder } = options;
const [editing, setEditing] = useState<boolean>(false);
const [hasFocus, setHasFocus] = useState<boolean>(false);
Expand Down Expand Up @@ -45,6 +46,8 @@ export const EditableField: React.FC<EditableFieldProps> = props => {
borderColor = localValue || transparentBorder ? 'transparent' : NeutralColors.gray30;
}

console.log(ariaLabel);
beyackle marked this conversation as resolved.
Show resolved Hide resolved

return (
<div onMouseEnter={() => setEditing(true)} onMouseLeave={() => !hasFocus && setEditing(false)}>
<TextField
Expand Down Expand Up @@ -77,6 +80,7 @@ export const EditableField: React.FC<EditableFieldProps> = props => {
onFocus={() => setHasFocus(true)}
onChange={handleChange}
autoComplete="off"
ariaLabel={ariaLabel}
{...rest}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const ChoiceItem: React.FC<ChoiceItemProps> = props => {
root: { margin: '7px 0 7px 0' },
}}
onBlur={handleBlur}
ariaLabel={formatMessage('Value')}
/>
</div>
<div css={choiceItemValue}>
Expand All @@ -97,6 +98,7 @@ const ChoiceItem: React.FC<ChoiceItemProps> = props => {
}}
options={{ transparentBorder: true }}
onBlur={handleBlur}
ariaLabel={formatMessage('Synonyms')}
/>
</div>
<div>
Expand Down Expand Up @@ -185,6 +187,7 @@ export const StaticChoices = props => {
placeholder={formatMessage('Add new option here')}
autoComplete="off"
errorMessage={errorMsg}
ariaLabel={formatMessage('Value')}
/>
</div>
<div css={choiceItemValue}>
Expand All @@ -198,6 +201,7 @@ export const StaticChoices = props => {
iconName: 'ReturnKey',
style: { color: SharedColors.cyanBlue10, opacity: 0.6 },
}}
ariaLabel={formatMessage('Synonyms')}
/>
</div>
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const RootField: React.FC<RootFieldProps> = props => {
onChange={handleTitleChange}
styles={{ field: { fontWeight: FontWeights.semibold }, root: { margin: '5px 0 7px -9px' } }}
fontSize={FontSizes.size20}
ariaLabel={formatMessage('Title')}
/>
<p className={classnames('RootFieldSubtitle', FontClassNames.smallPlus)}>{getSubTitle()}</p>
{sdkOverrides.description !== false && (description || schema.description) && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export function CheckboxWidget(props: BFDWidgetProps) {
onChange={(_, checked?: boolean) => onChange(checked)}
onBlur={() => onBlur && onBlur(id, Boolean(value))}
onFocus={() => onFocus && onFocus(id, Boolean(value))}
ariaLabel={label}
/>
<WidgetLabel label={label} description={description} id={id} inline />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ export function TextWidget(props: ITextWidgetProps) {
},
},
}}
ariaLabel={
// if we hide the widget label above, ARIA will need the label to exist here instead
hideLabel ? label : undefined
}
beyackle marked this conversation as resolved.
Show resolved Hide resolved
{...sharedProps}
/>
</>
Expand Down