diff options
author | Thibaut Girka <thib@sitedethib.com> | 2018-11-30 17:14:01 +0100 |
---|---|---|
committer | ThibG <thib@sitedethib.com> | 2018-11-30 22:37:38 +0100 |
commit | 76320bf6d8ff09cfbea911a5d0f466aa160d313f (patch) | |
tree | a57182011e8bd2a8d01ca54101caf2bef8ba150d /app | |
parent | a10fee3c09c268f0fd61a2f6ed03c6217934e383 (diff) |
Scroll to selected toot even if the ancestors happen to be loaded
Diffstat (limited to 'app')
-rw-r--r-- | app/javascript/flavours/glitch/features/status/index.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/javascript/flavours/glitch/features/status/index.js b/app/javascript/flavours/glitch/features/status/index.js index 018b52f1b..d2d5a05c8 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) { |