From 76320bf6d8ff09cfbea911a5d0f466aa160d313f 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) {