Просмотр исходного кода

Fix issue with focusable buttons

Occasionally, if a modal is opened as a result of clicking a button (ie
deleting a replica execution), the modal is re-opened after `Enter` due
to the fact that the button is focused and `Enter` triggers it's click.
Sergiu Miclea 8 лет назад
Родитель
Сommit
252e694d88

+ 1 - 1
src/components/atoms/Button/Button.jsx

@@ -108,7 +108,7 @@ const StyledButton = styled.button`
 
 const Button = ({ ...props }) => {
   return (
-    <StyledButton {...props} />
+    <StyledButton {...props} onFocus={e => { e.target.blur() }} />
   )
 }
 

+ 1 - 5
src/components/organisms/AlertModal/AlertModal.jsx

@@ -68,16 +68,12 @@ class AlertModal extends React.Component {
 
   componentWillReceiveProps(newProps) {
     if (newProps.isOpen && !this.props.isOpen) {
-      KeyboardManager.onEnter('alert', () => { this.handleEnter() }, 2)
+      KeyboardManager.onEnter('alert', () => { this.props.onConfirmation() }, 2)
     } else if (!newProps.isOpen && this.props.isOpen) {
       KeyboardManager.removeKeyDown('alert')
     }
   }
 
-  handleEnter() {
-    this.props.onConfirmation()
-  }
-
   renderDismissButton() {
     if (this.props.type !== 'error') {
       return null