Skip to content

Commit

Permalink
Allow navigation via tab key in welcome page
Browse files Browse the repository at this point in the history
fix brave/brave-browser#5504

Welcome page navigation via tab is impossible without this change
since all non-visible content is hidden visually but still accessible
via keyboard. This change fixes it and improves other element focus.
  • Loading branch information
cezaraugusto authored and bsclifton committed Oct 1, 2019
1 parent 495d1a9 commit 5747a8c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
16 changes: 13 additions & 3 deletions components/brave_welcome_ui/components/button/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const BaseButton = styled<BaseButtonProps, 'button'>('button')`
background: none;
border: none;
cursor: pointer;
outline: inherit;
outline: none;
`

export const FooterButton = styled(Button as ComponentType<ButtonProps>)`
Expand All @@ -45,6 +45,10 @@ export const SkipButton = styled(BaseButton)`
&:hover {
opacity: .9;
}
&:focus {
box-shadow: 0 0 0 2px rgba(33,37,41,0.2);
}
`

export const PrimaryButton = styled(Button as ComponentType<ButtonProps>)`
Expand All @@ -60,15 +64,21 @@ export const PrimaryButton = styled(Button as ComponentType<ButtonProps>)`
`

export const Bullet = styled(BaseButton as ComponentType<any>)`
padding: 0 7px;
font-size: 36px;
margin: 0 7px;
width: 11px;
height: 11px;
color: #7C7D8C;
letter-spacing: 0;
&:hover {
color: #343546;
}
&:focus {
box-shadow: 0 0 0 2px rgba(255,80,0,0.2);
border-radius: 50%;
}
${p => p.active && css`
color: #FB542B;
Expand Down
11 changes: 11 additions & 0 deletions components/brave_welcome_ui/components/wrapper/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ export const Content = styled<ContentProps, 'section'>('section')`
max-width: 580px;
padding: 24px;
/*
prevents focus on all content's child elements if the parent is not active.
this is needed because due to our animation transition, the parent container
cannot have "display: none" and is using "opacity: 0" instead, making invisible
elements still accessible via keyboard, creating an a11y issue.
see https://github.com/brave/brave-browser/issues/5504
*/
> * {
display: ${p => p.active === false && 'none'};
}
${p => p.active && css`
opacity: 1;
transform: translateX(0) scale(1);
Expand Down
4 changes: 3 additions & 1 deletion components/brave_welcome_ui/containers/screens/footerBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ export default class FooterBox extends React.PureComponent<Props, {}> {
key={k}
onClick={onClickSlideBullet.bind(this, k + 1)}
>
&bull;
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'>
<circle cx='8' cy='8' r='8' fill='currentColor' fillRule='evenodd' />
</svg>
</Bullet>
))}
</FooterMiddleColumn>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ export default class FooterBox extends React.PureComponent<Props, {}> {
</FooterLeftColumn>
<FooterMiddleColumn>
{Array.from({ length: totalScreensSize }, (v: undefined, k: number) => (
<Bullet active={currentScreen === k + 1} key={k} onClick={onClickSlideBullet.bind(this, k + 1)}>&bull;</Bullet>
<Bullet active={currentScreen === k + 1} key={k} onClick={onClickSlideBullet.bind(this, k + 1)}>
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'>
<circle cx='8' cy='8' r='8' fill='currentColor' fillRule='evenodd' />
</svg>
</Bullet>
))}
</FooterMiddleColumn>
<FooterRightColumn>
Expand Down

0 comments on commit 5747a8c

Please sign in to comment.