mirror of
https://github.com/mastodon/mastodon.git
synced 2025-10-05 00:22:42 +00:00
Allow accessing ref of ScrollContainer's child (#36265)
Some checks are pending
Check i18n / check-i18n (push) Waiting to run
Chromatic / Run Chromatic (push) Waiting to run
CodeQL / Analyze (actions) (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
CSS Linting / lint (push) Waiting to run
JavaScript Linting / lint (push) Waiting to run
JavaScript Testing / test (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.2) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Some checks are pending
Check i18n / check-i18n (push) Waiting to run
Chromatic / Run Chromatic (push) Waiting to run
CodeQL / Analyze (actions) (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
CSS Linting / lint (push) Waiting to run
JavaScript Linting / lint (push) Waiting to run
JavaScript Testing / test (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.2) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
This commit is contained in:
parent
d801cf8e59
commit
11bd515648
|
@ -399,7 +399,7 @@ class ScrollableList extends PureComponent {
|
||||||
|
|
||||||
if (trackScroll) {
|
if (trackScroll) {
|
||||||
return (
|
return (
|
||||||
<ScrollContainer scrollKey={scrollKey}>
|
<ScrollContainer scrollKey={scrollKey} childRef={this.setRef}>
|
||||||
{scrollableArea}
|
{scrollableArea}
|
||||||
</ScrollContainer>
|
</ScrollContainer>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
import React, { useContext, useEffect, useRef } from 'react';
|
import React, {
|
||||||
|
useContext,
|
||||||
|
useEffect,
|
||||||
|
useImperativeHandle,
|
||||||
|
useRef,
|
||||||
|
} from 'react';
|
||||||
|
|
||||||
import { defaultShouldUpdateScroll } from './default_should_update_scroll';
|
import { defaultShouldUpdateScroll } from './default_should_update_scroll';
|
||||||
import type { ShouldUpdateScrollFn } from './default_should_update_scroll';
|
import type { ShouldUpdateScrollFn } from './default_should_update_scroll';
|
||||||
|
@ -11,6 +16,7 @@ interface ScrollContainerProps {
|
||||||
*/
|
*/
|
||||||
scrollKey: string;
|
scrollKey: string;
|
||||||
shouldUpdateScroll?: ShouldUpdateScrollFn;
|
shouldUpdateScroll?: ShouldUpdateScrollFn;
|
||||||
|
childRef?: React.ForwardedRef<HTMLElement | undefined>;
|
||||||
children: React.ReactElement;
|
children: React.ReactElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,12 +29,20 @@ interface ScrollContainerProps {
|
||||||
export const ScrollContainer: React.FC<ScrollContainerProps> = ({
|
export const ScrollContainer: React.FC<ScrollContainerProps> = ({
|
||||||
children,
|
children,
|
||||||
scrollKey,
|
scrollKey,
|
||||||
|
childRef,
|
||||||
shouldUpdateScroll = defaultShouldUpdateScroll,
|
shouldUpdateScroll = defaultShouldUpdateScroll,
|
||||||
}) => {
|
}) => {
|
||||||
const scrollBehaviorContext = useContext(ScrollBehaviorContext);
|
const scrollBehaviorContext = useContext(ScrollBehaviorContext);
|
||||||
|
|
||||||
const containerRef = useRef<HTMLElement>();
|
const containerRef = useRef<HTMLElement>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If a childRef is passed, sync it with the containerRef. This
|
||||||
|
* is necessary because in this component's return statement,
|
||||||
|
* we're overwriting the immediate child component's ref prop.
|
||||||
|
*/
|
||||||
|
useImperativeHandle(childRef, () => containerRef.current, []);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register/unregister scrollable element with ScrollBehavior
|
* Register/unregister scrollable element with ScrollBehavior
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -602,7 +602,7 @@ class Status extends ImmutablePureComponent {
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ScrollContainer scrollKey='thread' shouldUpdateScroll={this.shouldUpdateScroll}>
|
<ScrollContainer scrollKey='thread' shouldUpdateScroll={this.shouldUpdateScroll} childRef={this.setContainerRef}>
|
||||||
<div className={classNames('scrollable item-list', { fullscreen })} ref={this.setContainerRef}>
|
<div className={classNames('scrollable item-list', { fullscreen })} ref={this.setContainerRef}>
|
||||||
{ancestors}
|
{ancestors}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user