diff --git a/app/renderer/components/navigation/urlBar.js b/app/renderer/components/navigation/urlBar.js index 4eba48ae0c0..7a5490b4048 100644 --- a/app/renderer/components/navigation/urlBar.js +++ b/app/renderer/components/navigation/urlBar.js @@ -311,13 +311,17 @@ class UrlBar extends React.Component { select () { if (this.urlInput) { - this.urlInput.select() + setImmediate(() => { + this.urlInput.select() + }) } } focus () { if (this.urlInput) { - this.urlInput.focus() + setImmediate(() => { + this.urlInput.focus() + }) } } diff --git a/app/renderer/components/reduxComponent.js b/app/renderer/components/reduxComponent.js index fec7ce502f5..538570fbed0 100644 --- a/app/renderer/components/reduxComponent.js +++ b/app/renderer/components/reduxComponent.js @@ -20,12 +20,13 @@ class ReduxComponent extends ImmutableComponent { super(props) this.componentType = props.componentType this.state = {} + this.internalState = props this.checkForUpdates = debounce(this.checkForUpdates.bind(this), 5) this.dontCheck = false } checkForUpdates () { - if (!this.dontCheck && this.shouldComponentUpdate(this.props, this.buildProps())) { + if (!this.dontCheck && this.shouldComponentUpdate(this.props)) { this.forceUpdate() } } @@ -33,7 +34,6 @@ class ReduxComponent extends ImmutableComponent { componentDidMount () { appStore.addChangeListener(this.checkForUpdates) windowStore.addChangeListener(this.checkForUpdates) - this.internalState = this.buildProps(this.props) } componentWillUnmount () { @@ -42,10 +42,6 @@ class ReduxComponent extends ImmutableComponent { windowStore.removeChangeListener(this.checkForUpdates) } - componentDidUpdate () { - this.internalState = this.buildProps(this.props) - } - checkParam (old, next, prop) { return isList(next[prop]) ? !isSameHashCode(next[prop], old[prop]) @@ -54,7 +50,11 @@ class ReduxComponent extends ImmutableComponent { shouldComponentUpdate (nextProps, nextState) { nextState = this.buildProps(nextProps) - return Object.keys(nextState).some((prop) => this.checkParam(this.internalState, nextState, prop)) + const shouldUpdate = Object.keys(nextState).some((prop) => this.checkParam(this.internalState, nextState, prop)) + if (shouldUpdate) { + this.internalState = nextState + } + return shouldUpdate } mergeProps (stateProps, dispatchProps, ownProps) { @@ -66,7 +66,7 @@ class ReduxComponent extends ImmutableComponent { } render () { - return React.createElement(this.componentType, this.buildProps()) + return React.createElement(this.componentType, this.internalState) } } diff --git a/app/renderer/components/tabs/tab.js b/app/renderer/components/tabs/tab.js index 1dadf1adbeb..c1b3ac1874d 100644 --- a/app/renderer/components/tabs/tab.js +++ b/app/renderer/components/tabs/tab.js @@ -230,9 +230,11 @@ class Tab extends ImmutableComponent { } onUpdateTabSize () { - const currentSize = getTabBreakpoint(this.tabSize) - // Avoid updating breakpoint when user enters fullscreen (see #7301) - !this.props.hasTabInFullScreen && windowActions.setTabBreakpoint(this.frame, currentSize) + setImmediate(() => { + const currentSize = getTabBreakpoint(this.tabSize) + // Avoid updating breakpoint when user enters fullscreen (see #7301) + !this.props.hasTabInFullScreen && windowActions.setTabBreakpoint(this.frame, currentSize) + }) } componentWillMount () { diff --git a/js/dispatcher/appDispatcher.js b/js/dispatcher/appDispatcher.js index dd1b843921d..23c786da011 100644 --- a/js/dispatcher/appDispatcher.js +++ b/js/dispatcher/appDispatcher.js @@ -65,7 +65,7 @@ class AppDispatcher { dispatchCargo.push(payload) } else { this.dispatching = true - this.dispatchInternal(payload, doneDispatching) + setImmediate(this.dispatchInternal.bind(this, payload, doneDispatching)) } }