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: accessibility issue on create new bot dialog #2683

Merged
merged 3 commits into from
Apr 17, 2020
Merged
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
24 changes: 14 additions & 10 deletions Composer/packages/client/src/CreationFlow/CreateOptions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ import { Sticky, StickyPositionType } from 'office-ui-fabric-react/lib/Sticky';

import { detailListContainer, listHeader, rowDetails, rowTitle, optionRoot, optionIcon } from './styles';

const optionKeys = {
createFromScratch: 'createFromScratch',
createFromTemplate: 'createFromTemplate',
};

export function CreateOptions(props) {
const [option, setOption] = useState('CreateFromScratch');
const [option, setOption] = useState(optionKeys.createFromScratch);
const [disabled, setDisabled] = useState(true);
const { templates, onDismiss, onNext } = props;
const emptyBotKey = templates[1].id;
Expand All @@ -49,15 +54,15 @@ export function CreateOptions(props) {

const handleChange = (event, option) => {
setOption(option.key);
if (option.key === 'CreateFromTemplate') {
if (option.key === optionKeys.createFromTemplate) {
setDisabled(false);
} else {
setDisabled(true);
}
};

const handleJumpToNext = () => {
if (option === 'CreateFromTemplate') {
if (option === optionKeys.createFromTemplate) {
onNext(template);
} else {
onNext(emptyBotKey);
Expand Down Expand Up @@ -110,25 +115,24 @@ export function CreateOptions(props) {
<Fragment>
<ChoiceGroup
label={formatMessage('Choose how to create your bot')}
defaultSelectedKey="CreateFromScratch"
selectedKey={option}
options={[
{
ariaLabel: 'Create from scratch',
key: 'CreateFromScratch',
ariaLabel: 'Create from scratch' + (option === optionKeys.createFromScratch ? ' selected' : ''),
key: optionKeys.createFromScratch,
'data-testid': 'Create from scratch',
text: formatMessage('Create from scratch'),
onRenderField: SelectOption,
},
{
ariaLabel: 'Create from template',
key: 'CreateFromTemplate',
ariaLabel: 'Create from template' + (option === optionKeys.createFromTemplate ? ' selected' : ''),
key: optionKeys.createFromTemplate,
'data-testid': 'Create from template',
text: formatMessage('Create from template'),
onRenderField: SelectOption,
},
]}
onChange={handleChange}
required={true}
/>
<h3 css={listHeader}>{formatMessage('Examples')}</h3>
<div data-is-scrollable="true" css={detailListContainer}>
Expand All @@ -151,7 +155,7 @@ export function CreateOptions(props) {
<DialogFooter>
<DefaultButton onClick={onDismiss} text={formatMessage('Cancel')} />
<PrimaryButton
disabled={option === 'CreateFromTemplate' && (templates.length <= 0 || template === null)}
disabled={option === optionKeys.createFromTemplate && (templates.length <= 0 || template === null)}
onClick={handleJumpToNext}
text={formatMessage('Next')}
data-testid="NextStepButton"
Expand Down