From 41141a62ac2b0ccc4432ae8302bdfaa39a1ffa14 Mon Sep 17 00:00:00 2001 From: Benjamin Flores Date: Mon, 24 Oct 2016 22:09:32 -0300 Subject: [PATCH 1/2] fixed issue with focus in email and user input --- src/ui/box/container.jsx | 15 +-------------- src/ui/input/email_input.jsx | 5 +++-- src/ui/input/username_input.jsx | 4 +++- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/ui/box/container.jsx b/src/ui/box/container.jsx index c63a57ab2..6b327e74a 100644 --- a/src/ui/box/container.jsx +++ b/src/ui/box/container.jsx @@ -3,20 +3,7 @@ import Chrome from './chrome'; import { CloseButton } from './button'; const badgeSvg = ( - - - - - - - - - - - - - - + ); const BottomBadge = ({link}) => ( diff --git a/src/ui/input/email_input.jsx b/src/ui/input/email_input.jsx index 255d4ae33..aab9a2b3e 100644 --- a/src/ui/input/email_input.jsx +++ b/src/ui/input/email_input.jsx @@ -1,7 +1,6 @@ import React from 'react'; import InputWrap from './input_wrap'; - const svg = ''; export default class EmailInput extends React.Component { @@ -12,10 +11,12 @@ export default class EmailInput extends React.Component { shouldComponentUpdate(nextProps) { const { invalidHint, isValid, value, onChange } = this.props; + const { focused } = this.state; return invalidHint != nextProps.invalidHint || isValid != nextProps.isValid - || value != nextProps.value; + || value != nextProps.value + || !focused != nextProps.focused; } render() { diff --git a/src/ui/input/username_input.jsx b/src/ui/input/username_input.jsx index e8342a4ba..a748589e1 100644 --- a/src/ui/input/username_input.jsx +++ b/src/ui/input/username_input.jsx @@ -11,10 +11,12 @@ export default class UsernameInput extends React.Component { shouldComponentUpdate(nextProps) { const { invalidHint, isValid, value, onChange } = this.props; + const { focused } = this.state; return invalidHint != nextProps.invalidHint || isValid != nextProps.isValid - || value != nextProps.value; + || value != nextProps.value + || !focused != nextProps.focused; } render() { From b13f893a598afc03164db2eac8775ec34421dc0e Mon Sep 17 00:00:00 2001 From: Gabriel Andretta Date: Wed, 26 Oct 2016 11:40:06 -0300 Subject: [PATCH 2/2] Fix input's shouldComponentUpdate check The "focused" value from the state was being compared with the "focused" value from the next props, instead of the "focused" value from next state. --- src/ui/input/email_input.jsx | 4 ++-- src/ui/input/username_input.jsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ui/input/email_input.jsx b/src/ui/input/email_input.jsx index aab9a2b3e..f06697164 100644 --- a/src/ui/input/email_input.jsx +++ b/src/ui/input/email_input.jsx @@ -9,14 +9,14 @@ export default class EmailInput extends React.Component { this.state = {}; } - shouldComponentUpdate(nextProps) { + shouldComponentUpdate(nextProps, nextState) { const { invalidHint, isValid, value, onChange } = this.props; const { focused } = this.state; return invalidHint != nextProps.invalidHint || isValid != nextProps.isValid || value != nextProps.value - || !focused != nextProps.focused; + || focused != nextState.focused; } render() { diff --git a/src/ui/input/username_input.jsx b/src/ui/input/username_input.jsx index a748589e1..19acacb4c 100644 --- a/src/ui/input/username_input.jsx +++ b/src/ui/input/username_input.jsx @@ -9,14 +9,14 @@ export default class UsernameInput extends React.Component { this.state = {}; } - shouldComponentUpdate(nextProps) { + shouldComponentUpdate(nextProps, nextState) { const { invalidHint, isValid, value, onChange } = this.props; const { focused } = this.state; return invalidHint != nextProps.invalidHint || isValid != nextProps.isValid || value != nextProps.value - || !focused != nextProps.focused; + || focused != nextState.focused; } render() {