Test fix scroll position when opening media on the side
This commit is contained in:
parent
6dd6e0e77c
commit
372e86415b
|
@ -167,6 +167,7 @@ function StatusPage(params) {
|
|||
function StatusThread({ id, closeLink = '/', instance: propInstance }) {
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
const mediaParam = searchParams.get('media');
|
||||
const mediaStatusID = searchParams.get('mediaStatusID');
|
||||
const showMedia = parseInt(mediaParam, 10) > 0;
|
||||
const firstLoad = useRef(!states.prevLocation && history.length === 1);
|
||||
const [viewMode, setViewMode] = useState(
|
||||
|
@ -657,6 +658,23 @@ function StatusThread({ id, closeLink = '/', instance: propInstance }) {
|
|||
resetScrollPosition(status.id);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
let timer;
|
||||
if (mediaStatusID && showMedia) {
|
||||
timer = setTimeout(() => {
|
||||
const status = scrollableRef.current?.querySelector(
|
||||
`.status-link[href*="/${mediaStatusID}"]`,
|
||||
);
|
||||
if (status) {
|
||||
status.scrollIntoView(scrollIntoViewOptions);
|
||||
}
|
||||
}, 400); // After CSS transition
|
||||
}
|
||||
return () => {
|
||||
clearTimeout(timer);
|
||||
};
|
||||
}, [mediaStatusID, showMedia]);
|
||||
|
||||
const renderStatus = useCallback(
|
||||
(status) => {
|
||||
const {
|
||||
|
|
Loading…
Reference in a new issue