Skip to content

Commit

Permalink
fix accessibility issue on create new bot dialog (#2683)
Browse files Browse the repository at this point in the history
Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com>
  • Loading branch information
liweitian and corinagum authored Apr 17, 2020
1 parent 7af6272 commit 60aa477
Showing 1 changed file with 14 additions and 10 deletions.
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

0 comments on commit 60aa477

Please sign in to comment.