Skip to content

Commit

Permalink
Merge pull request #4736 from brave/ksmith-tip-dialog-esc
Browse files Browse the repository at this point in the history
Escape key should always close the tip dialog
  • Loading branch information
zenparsing authored Feb 28, 2020
2 parents c0fac90 + 033e60b commit af9e381
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
6 changes: 6 additions & 0 deletions components/brave_rewards/resources/tip/brave_rewards_tip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ window.cr.define('brave_rewards_tip', function () {
console.error('Error parsing incoming dialog args', dialogArgsRaw, e)
}

document.body.addEventListener('keyup', (evt) => {
if (evt.key.toLowerCase() === 'escape') {
getActions().onCloseDialog()
}
})

render(
<Provider store={store}>
<ThemeProvider theme={Theme}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,6 @@ export default class SiteBanner extends React.PureComponent<Props, {}> {
}
}

onKeyUp = (e: React.KeyboardEvent<HTMLDivElement>) => {
if (e.key.toLowerCase() === 'escape' && this.props.onClose) {
this.props.onClose()
}
}

renderConfirmation = () => {
const { type, onTweet, onlyAnonWallet, monthlyDate, amount } = this.props

Expand Down Expand Up @@ -286,11 +280,7 @@ export default class SiteBanner extends React.PureComponent<Props, {}> {
const batFormatString = onlyAnonWallet ? 'bap' : 'bat'

return (
<StyledWrapper
id={id}
onKeyUp={this.onKeyUp}
tabIndex={0}
>
<StyledWrapper id={id} tabIndex={0}>
<StyledBanner>
<StyledClose onClick={onClose}>
<CloseCircleOIcon />
Expand Down

0 comments on commit af9e381

Please sign in to comment.