From 7d58968ea619cd96dd7f57d5a0d24e0c7f362360 Mon Sep 17 00:00:00 2001 From: wmwragg Date: Mon, 12 Sep 2016 14:07:51 +0100 Subject: [PATCH] Correctly positioning the selected element if list shrinks in size --- src/components/views/elements/AddressSelector.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/views/elements/AddressSelector.js b/src/components/views/elements/AddressSelector.js index 095f2888cd..cd62705809 100644 --- a/src/components/views/elements/AddressSelector.js +++ b/src/components/views/elements/AddressSelector.js @@ -37,14 +37,16 @@ module.exports = React.createClass({ }; }, - componentDidUpdate: function() { + componentWillReceiveProps: function(props) { // Make sure the selected item isn't outside the list bounds var selected = this.state.selected; - var maxSelected = this._maxSelected(this.props.addressList); + var maxSelected = this._maxSelected(props.addressList); if (selected > maxSelected) { - selected = maxSelected; + this.setState({ selected: maxSelected }); } + }, + componentDidUpdate: function() { // As the user scrolls with the arrow keys keep the selected item // at the top of the window. if (this.scrollElement && this.props.addressList.length > 0 && !this.state.hover) {