Skip to content

Commit

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

* no-unused-vars
  • Loading branch information
rickycodes authored Jan 7, 2020
1 parent c66449f commit 984e5a1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 29 deletions.
58 changes: 30 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,35 @@ 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 @@ -297,9 +297,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 984e5a1

Please sign in to comment.