Skip to content

Commit

Permalink
fix(currencyswap): [a11y] swap button focus color feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulFasola committed Apr 4, 2021
1 parent 7a70a56 commit 2c11e7a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/components/CurrencySwap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,13 @@ const CurrencySwap: React.FC<IProps> = (props) => {
</InputWrapper>
<SwapButton
aria-label={strs.swapBtnLabel}
onClick={() => {
onClick={(e) => {
// unfocus when the user clicks on the button since this last will keep the focus
// that event shouldn't be trigerred while using keyboard navigation for accessibility reasons
if (e.screenX > 0 && e.screenY) {
e.currentTarget.blur();
}

setSwapValues({ input: swapValues.output, output: swapValues.input });
/* istanbul ignore next */
setActiveProtocols({ input: activeProtocols?.output, output: activeProtocols?.input });
Expand Down
11 changes: 8 additions & 3 deletions src/components/CurrencySwap/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ export const SwapButton = styled.button`
background: transparent;
cursor: pointer;
&:hover path {
&:hover path,
&:focus path {
transition: fill 0.15s ease-in;
fill: ${(p) => _(p.theme, 'disabled', 'color')}!important;
}
Expand Down Expand Up @@ -100,8 +102,11 @@ export const SubmitButton = styled.button`
cursor: auto;
}
&:hover:not(:disabled) {
background-color: ${(p) => _(p.theme, 'defaultButton', 'hoverBgColor')};
&:hover,
&:focus {
&:not(:disabled) {
background-color: ${(p) => _(p.theme, 'defaultButton', 'hoverBgColor')};
}
}
`;

Expand Down

0 comments on commit 2c11e7a

Please sign in to comment.