Skip to content

Commit

Permalink
fix: rich text editor btn aria label
Browse files Browse the repository at this point in the history
  • Loading branch information
chaofan232 committed Sep 6, 2022
1 parent 28d7d83 commit 9cc9b12
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/components/RichTextEditor/BlockStyleButtons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import BulletIcon from '../../styles/icons/bullet.svg';
import NumberIcon from '../../styles/icons/number.svg';

const BLOCK_TYPES = [
{ label: <BulletIcon data-testid="bullet" />, style: 'unordered-list-item' },
{ label: <NumberIcon data-testid="number" />, style: 'ordered-list-item' },
{ label: <BulletIcon data-testid="bullet" />, style: 'unordered-list-item', ariaLabel: 'Unordered list' },
{ label: <NumberIcon data-testid="number" />, style: 'ordered-list-item', ariaLabel: 'Ordered list' },
];

const BlockStyleButtons = (props) => {
Expand All @@ -24,7 +24,7 @@ const BlockStyleButtons = (props) => {
active={type.style === blockType}
label={type.label}
onToggle={() => onToggle(type.style)}
style={type.style}
aria-label={type.ariaLabel}
/>
));
};
Expand Down
1 change: 1 addition & 0 deletions src/components/RichTextEditor/FileUploadAction.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const FileUploadAction = ({ onFileUpload, fileFilter }) => {
fileInputRef.current.value = '';
fileInputRef.current.click();
}}
aria-label="Download file"
/>
<input
data-testid="file-download-input"
Expand Down
12 changes: 8 additions & 4 deletions src/components/RichTextEditor/InlineStyleButtons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ import ItalicIcon from '../../styles/icons/italic.svg';
import UnderlineIcon from '../../styles/icons/underline.svg';

const INLINE_STYLES = [
{ label: <BoldIcon data-testid="bold" />, style: 'BOLD' },
{ label: <ItalicIcon data-testid="italics" />, style: 'ITALIC' },
{ label: <UnderlineIcon data-testid="underline" />, style: 'UNDERLINE' },
{ label: <BoldIcon data-testid="bold" />, style: 'BOLD', ariaLabel: 'Bold' },
{ label: <ItalicIcon data-testid="italics" aria-label="italic" />, style: 'ITALIC', ariaLabel: 'Italic' },
{
label: <UnderlineIcon data-testid="underline" aria-label="Underline" />,
style: 'UNDERLINE',
ariaLabel: 'Underline',
},
];

const InlineStyleButtons = (props) => {
Expand All @@ -24,7 +28,7 @@ const InlineStyleButtons = (props) => {
active={currentStyle.has(type.style)}
label={type.label}
onToggle={() => onToggle(type.style)}
style={type.style}
aria-label={type.ariaLabel}
/>
));
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/RichTextEditor/MentionAction.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import ToolbarButton from './ToolbarButton';

const MentionAction = ({ onToggle }) => (
<ToolbarButton label={<div className="mention-button">@</div>} onToggle={onToggle} />
<ToolbarButton label={<div className="mention-button">@</div>} onToggle={onToggle} aria-label="Mention" />
);

export default MentionAction;
Expand Down
4 changes: 2 additions & 2 deletions src/components/RichTextEditor/ToolbarButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import classnames from 'classnames';
import Button from '../Button';

const ToolbarButton = ({ onToggle, label, active }) => {
const ToolbarButton = ({ onToggle, label, active, ...rest }) => {
const className = classnames('aui--toolbar-button', {
active,
});
Expand All @@ -18,7 +18,7 @@ const ToolbarButton = ({ onToggle, label, active }) => {
);

return (
<Button className={className} onMouseDown={mouseDownHandler}>
<Button className={className} onMouseDown={mouseDownHandler} {...rest}>
{label}
</Button>
);
Expand Down

0 comments on commit 9cc9b12

Please sign in to comment.