From ddf10f52a7c455b0d3a4dca0a85b928b4e970da8 Mon Sep 17 00:00:00 2001 From: Clworld Date: Thu, 7 Sep 2017 00:29:56 +0900 Subject: [PATCH] fix scroll position (#4821) --- app/javascript/mastodon/components/scrollable_list.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/javascript/mastodon/components/scrollable_list.js b/app/javascript/mastodon/components/scrollable_list.js index 1a122dbe58..e47b1e9aa5 100644 --- a/app/javascript/mastodon/components/scrollable_list.js +++ b/app/javascript/mastodon/components/scrollable_list.js @@ -5,6 +5,7 @@ import IntersectionObserverArticle from './intersection_observer_article'; import LoadMore from './load_more'; import IntersectionObserverWrapper from '../features/ui/util/intersection_observer_wrapper'; import { throttle } from 'lodash'; +import { List as ImmutableList } from 'immutable'; export default class ScrollableList extends PureComponent { @@ -95,7 +96,12 @@ export default class ScrollableList extends PureComponent { getFirstChildKey (props) { const { children } = props; - const firstChild = Array.isArray(children) ? children[0] : children; + let firstChild = children; + if (children instanceof ImmutableList) { + firstChild = children.get(0); + } else if (Array.isArray(children)) { + firstChild = children[0]; + } return firstChild && firstChild.key; }