Skip to content
This repository has been archived by the owner on Oct 28, 2022. It is now read-only.

Commit

Permalink
Properly handle <enter> keystroke (MetaMask#7747)
Browse files Browse the repository at this point in the history
* Properly handle <enter> keystroke, closes MetaMask#7737

* no-unused-vars
  • Loading branch information
rickycodes authored and yqrashawn committed Jan 14, 2020
1 parent 8a12f30 commit 3179d2d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 29 deletions.
65 changes: 37 additions & 28 deletions ui/app/components/ui/button/button.component.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from 'react'
import React from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'

Expand All @@ -24,33 +24,42 @@ const typeHash = {
'first-time': CLASSNAME_FIRST_TIME,
}

export default class Button extends Component {
static propTypes = {
type: PropTypes.string,
large: PropTypes.bool,
className: PropTypes.string,
children: PropTypes.oneOfType([
PropTypes.string,
PropTypes.array,
PropTypes.element,
]),
}
const Button = ({
type,
submit,
large,
children,
className,
...buttonProps
}) => (
<button
type={submit && 'submit'}
className={classnames(
'button',
typeHash[type] || CLASSNAME_DEFAULT,
large && CLASSNAME_LARGE,
className
)}
{...buttonProps}
>
{children}
</button>
)

render () {
const { type, large, className, ...buttonProps } = this.props
Button.propTypes = {
type: PropTypes.string,
submit: PropTypes.bool,
large: PropTypes.bool,
className: PropTypes.string,
children: PropTypes.oneOfType([
PropTypes.string,
PropTypes.array,
PropTypes.element,
]),
}

return (
<button
className={classnames(
'button',
typeHash[type] || CLASSNAME_DEFAULT,
large && CLASSNAME_LARGE,
className
)}
{...buttonProps}
>
{this.props.children}
</button>
)
}
Button.defaultProps = {
submit: false,
}

export default Button
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ export default class ImportWithSeedPhrase extends PureComponent {
</div>
<Button
type="primary"
submit
className="first-time-flow__button"
disabled={!this.isValid() || !termsChecked}
onClick={this.handleImport}
>
{t('import')}
</Button>
Expand Down

0 comments on commit 3179d2d

Please sign in to comment.