Correctly positioning the selected element if list shrinks in size
parent
28dcbb2a78
commit
7d58968ea6
|
@ -37,14 +37,16 @@ module.exports = React.createClass({
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidUpdate: function() {
|
componentWillReceiveProps: function(props) {
|
||||||
// Make sure the selected item isn't outside the list bounds
|
// Make sure the selected item isn't outside the list bounds
|
||||||
var selected = this.state.selected;
|
var selected = this.state.selected;
|
||||||
var maxSelected = this._maxSelected(this.props.addressList);
|
var maxSelected = this._maxSelected(props.addressList);
|
||||||
if (selected > maxSelected) {
|
if (selected > maxSelected) {
|
||||||
selected = maxSelected;
|
this.setState({ selected: maxSelected });
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
componentDidUpdate: function() {
|
||||||
// As the user scrolls with the arrow keys keep the selected item
|
// As the user scrolls with the arrow keys keep the selected item
|
||||||
// at the top of the window.
|
// at the top of the window.
|
||||||
if (this.scrollElement && this.props.addressList.length > 0 && !this.state.hover) {
|
if (this.scrollElement && this.props.addressList.length > 0 && !this.state.hover) {
|
||||||
|
|
Loading…
Reference in New Issue