mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-26 04:55:07 +01:00
Fix scrolling to detailed status not always working (#28577)
This commit is contained in:
parent
419c659bc4
commit
d0fd14f851
@ -582,16 +582,20 @@ class Status extends ImmutablePureComponent {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
setRef = c => {
|
setContainerRef = c => {
|
||||||
this.node = c;
|
this.node = c;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
setStatusRef = c => {
|
||||||
|
this.statusNode = c;
|
||||||
|
};
|
||||||
|
|
||||||
_scrollStatusIntoView () {
|
_scrollStatusIntoView () {
|
||||||
const { status, multiColumn } = this.props;
|
const { status, multiColumn } = this.props;
|
||||||
|
|
||||||
if (status) {
|
if (status) {
|
||||||
window.requestAnimationFrame(() => {
|
requestIdleCallback(() => {
|
||||||
this.node?.querySelector('.detailed-status__wrapper')?.scrollIntoView(true);
|
this.statusNode?.scrollIntoView(true);
|
||||||
|
|
||||||
// In the single-column interface, `scrollIntoView` will put the post behind the header,
|
// In the single-column interface, `scrollIntoView` will put the post behind the header,
|
||||||
// so compensate for that.
|
// so compensate for that.
|
||||||
@ -629,9 +633,8 @@ class Status extends ImmutablePureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Scroll to focused post if it is loaded
|
// Scroll to focused post if it is loaded
|
||||||
const child = this.node?.querySelector('.detailed-status__wrapper');
|
if (this.statusNode) {
|
||||||
if (child) {
|
return [0, this.statusNode.offsetTop];
|
||||||
return [0, child.offsetTop];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not scroll otherwise, `componentDidUpdate` will take care of that
|
// Do not scroll otherwise, `componentDidUpdate` will take care of that
|
||||||
@ -692,11 +695,11 @@ class Status extends ImmutablePureComponent {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<ScrollContainer scrollKey='thread' shouldUpdateScroll={this.shouldUpdateScroll}>
|
<ScrollContainer scrollKey='thread' shouldUpdateScroll={this.shouldUpdateScroll}>
|
||||||
<div className={classNames('scrollable', { fullscreen })} ref={this.setRef}>
|
<div className={classNames('scrollable', { fullscreen })} ref={this.setContainerRef}>
|
||||||
{ancestors}
|
{ancestors}
|
||||||
|
|
||||||
<HotKeys handlers={handlers}>
|
<HotKeys handlers={handlers}>
|
||||||
<div className={classNames('focusable', 'detailed-status__wrapper', `detailed-status__wrapper-${status.get('visibility')}`)} tabIndex={0} aria-label={textForScreenReader(intl, status, false)}>
|
<div className={classNames('focusable', 'detailed-status__wrapper', `detailed-status__wrapper-${status.get('visibility')}`)} tabIndex={0} aria-label={textForScreenReader(intl, status, false)} ref={this.setStatusRef}>
|
||||||
<DetailedStatus
|
<DetailedStatus
|
||||||
key={`details-${status.get('id')}`}
|
key={`details-${status.get('id')}`}
|
||||||
status={status}
|
status={status}
|
||||||
|
Loading…
Reference in New Issue
Block a user