prevent error for empty list

This commit is contained in:
Bruno Windels 2019-11-06 10:31:56 +01:00
parent eb4220a836
commit 9fa7990996

View file

@ -759,8 +759,10 @@ module.exports = createReactClass({
_getMessagesHeight() { _getMessagesHeight() {
const itemlist = this.refs.itemlist; const itemlist = this.refs.itemlist;
const lastNode = itemlist.lastElementChild; const lastNode = itemlist.lastElementChild;
const lastNodeBottom = lastNode ? lastNode.offsetTop + lastNode.clientHeight : 0;
const firstNodeTop = itemlist.firstElementChild ? itemlist.firstElementChild.offsetTop : 0;
// 18 is itemlist padding // 18 is itemlist padding
return (lastNode.offsetTop + lastNode.clientHeight) - itemlist.firstElementChild.offsetTop + (18 * 2); return lastNodeBottom - firstNodeTop + (18 * 2);
}, },
_topFromBottom(node) { _topFromBottom(node) {