From a281d3ebd320071dd4044dd59d0a2720623b46e1 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Fri, 30 Nov 2018 17:14:01 +0100 Subject: [PATCH] Scroll to selected toot even if the ancestors happen to be loaded --- .../flavours/glitch/features/status/index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/javascript/flavours/glitch/features/status/index.js b/app/javascript/flavours/glitch/features/status/index.js index 018b52f1b1..d2d5a05c80 100644 --- a/app/javascript/flavours/glitch/features/status/index.js +++ b/app/javascript/flavours/glitch/features/status/index.js @@ -134,6 +134,16 @@ export default class Status extends ImmutablePureComponent { componentDidMount () { attachFullscreenListener(this.onFullScreenChange); this.props.dispatch(fetchStatus(this.props.params.statusId)); + + const { status, ancestorsIds } = this.props; + + if (status && ancestorsIds && ancestorsIds.size > 0) { + const element = this.node.querySelectorAll('.focusable')[ancestorsIds.size - 1]; + + window.requestAnimationFrame(() => { + element.scrollIntoView(true); + }); + } } static getDerivedStateFromProps(props, state) {