Skip to content

Commit

Permalink
fix(protocolselector): WCAG2AA - Elements with scrollable content mus…
Browse files Browse the repository at this point in the history
…t be keyboard accessible
  • Loading branch information
PaulFasola committed Mar 25, 2021
1 parent aa47ec1 commit 3bed194
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/components/ProtocolSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export const ProtocolSelector: React.FC<IProps> = (props) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [props.current]);

const _handleProtocolPick = (protocol: IProtocol) => (): void => {
const handleProtocolPick = (protocol: IProtocol) => (): void => {
console.log(protocol);
if (typeof props.onChange === 'function') {
props.onChange(protocol);
}
Expand Down Expand Up @@ -80,9 +81,14 @@ export const ProtocolSelector: React.FC<IProps> = (props) => {
return (
<>
{button}
<DropDownList data-test='dropdown' open={dropdownIsOpen} ref={dropdownRef}>
<DropDownList data-test='dropdown' open={dropdownIsOpen} tabIndex={0} ref={dropdownRef}>
{props.list.map((protocol, i) => (
<div key={i} onClick={_handleProtocolPick(protocol)}>
<div
key={i}
onClick={handleProtocolPick(protocol)}
onKeyPress={(e) => e.key === 'Enter' && handleProtocolPick(protocol)()}
tabIndex={0}
>
<ProtocolIcon src={protocol.logoURI} title={fullLabel} />
<div>{protocol.name}</div>
<div>{protocol.symbol}</div>
Expand Down
3 changes: 2 additions & 1 deletion src/components/ProtocolSelector/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export const Button = styled.button`
&:not(:disabled) {
cursor: pointer;
&:hover {
&:hover,
&:focus {
background-color: ${({ theme }) => _(theme, 'defaultButton', 'hoverBgColor')};
}
}
Expand Down

0 comments on commit 3bed194

Please sign in to comment.