[FIX] Scroll to top crashing when ref is undefined (#2252)
* [FIX] Check if exists scroll ref * Remove scrollTo Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
parent
83fbb8c304
commit
362ef0085e
|
@ -769,7 +769,7 @@ class RoomView extends React.Component {
|
||||||
if (handleCommandScroll(event)) {
|
if (handleCommandScroll(event)) {
|
||||||
const offset = input === 'UIKeyInputUpArrow' ? 100 : -100;
|
const offset = input === 'UIKeyInputUpArrow' ? 100 : -100;
|
||||||
this.offset += offset;
|
this.offset += offset;
|
||||||
this.flatList.scrollToOffset({ offset: this.offset });
|
this.flatList?.scrollToOffset({ offset: this.offset });
|
||||||
} else if (handleCommandRoomActions(event)) {
|
} else if (handleCommandRoomActions(event)) {
|
||||||
this.goRoomActionsView();
|
this.goRoomActionsView();
|
||||||
} else if (handleCommandSearchMessages(event)) {
|
} else if (handleCommandSearchMessages(event)) {
|
||||||
|
|
|
@ -512,12 +512,7 @@ class RoomsListView extends React.Component {
|
||||||
this.setHeader();
|
this.setHeader();
|
||||||
closeSearchHeader();
|
closeSearchHeader();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const offset = 0;
|
this.scrollToTop();
|
||||||
if (this.scroll.scrollTo) {
|
|
||||||
this.scroll.scrollTo({ x: 0, y: offset, animated: true });
|
|
||||||
} else if (this.scroll.scrollToOffset) {
|
|
||||||
this.scroll.scrollToOffset({ offset });
|
|
||||||
}
|
|
||||||
}, 200);
|
}, 200);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -546,9 +541,7 @@ class RoomsListView extends React.Component {
|
||||||
search: result,
|
search: result,
|
||||||
searching: true
|
searching: true
|
||||||
});
|
});
|
||||||
if (this.scroll && this.scroll.scrollTo) {
|
this.scrollToTop();
|
||||||
this.scroll.scrollTo({ x: 0, y: 0, animated: true });
|
|
||||||
}
|
|
||||||
}, 300);
|
}, 300);
|
||||||
|
|
||||||
getRoomTitle = item => RocketChat.getRoomTitle(item)
|
getRoomTitle = item => RocketChat.getRoomTitle(item)
|
||||||
|
@ -569,15 +562,16 @@ class RoomsListView extends React.Component {
|
||||||
this.goRoom({ item, isMasterDetail });
|
this.goRoom({ item, isMasterDetail });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
scrollToTop = () => {
|
||||||
|
if (this.scroll?.scrollToOffset) {
|
||||||
|
this.scroll.scrollToOffset({ offset: 0 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
toggleSort = () => {
|
toggleSort = () => {
|
||||||
const { toggleSortDropdown } = this.props;
|
const { toggleSortDropdown } = this.props;
|
||||||
|
|
||||||
const offset = 0;
|
this.scrollToTop();
|
||||||
if (this.scroll.scrollTo) {
|
|
||||||
this.scroll.scrollTo({ x: 0, y: offset, animated: true });
|
|
||||||
} else if (this.scroll.scrollToOffset) {
|
|
||||||
this.scroll.scrollToOffset({ offset });
|
|
||||||
}
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
toggleSortDropdown();
|
toggleSortDropdown();
|
||||||
}, 100);
|
}, 100);
|
||||||
|
|
Loading…
Reference in New Issue