mirror of
https://github.com/element-hq/element-web
synced 2024-11-23 17:56:01 +03:00
Correctly positioning the selected element if list shrinks in size
This commit is contained in:
parent
28dcbb2a78
commit
7d58968ea6
1 changed files with 5 additions and 3 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue