Fix message reaction picker moving when typing stops

This commit is contained in:
ayumi-signal 2025-02-05 12:13:37 -08:00 committed by GitHub
parent 238e7be2ee
commit a3e28478bd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 2 deletions

View file

@ -5946,6 +5946,10 @@ button.module-calling-participants-list__contact {
overflow-anchor: auto; overflow-anchor: auto;
} }
} }
&--scroll-locked {
// Component also applies flex-basis to prevent shrinkage
flex-shrink: 0;
}
&--have-oldest { &--have-oldest {
justify-content: flex-start; justify-content: flex-start;

View file

@ -167,6 +167,7 @@ export type PropsType = PropsDataType &
type StateType = { type StateType = {
scrollLocked: boolean; scrollLocked: boolean;
scrollLockHeight: number | undefined;
hasDismissedDirectContactSpoofingWarning: boolean; hasDismissedDirectContactSpoofingWarning: boolean;
hasRecentlyScrolled: boolean; hasRecentlyScrolled: boolean;
lastMeasuredWarningHeight: number; lastMeasuredWarningHeight: number;
@ -205,6 +206,7 @@ export class Timeline extends React.Component<
// eslint-disable-next-line react/state-in-constructor // eslint-disable-next-line react/state-in-constructor
override state: StateType = { override state: StateType = {
scrollLocked: false, scrollLocked: false,
scrollLockHeight: undefined,
hasRecentlyScrolled: true, hasRecentlyScrolled: true,
hasDismissedDirectContactSpoofingWarning: false, hasDismissedDirectContactSpoofingWarning: false,
@ -214,8 +216,16 @@ export class Timeline extends React.Component<
}; };
#onScrollLockChange = (): void => { #onScrollLockChange = (): void => {
this.setState({ const scrollLocked = this.#scrollerLock.isLocked();
scrollLocked: this.#scrollerLock.isLocked(), this.setState(() => {
// Prevent scroll due to elements shrinking or disappearing (e.g. typing indicators)
const scrollLockHeight = scrollLocked
? this.#messagesRef.current?.offsetHeight
: undefined;
return {
scrollLocked,
scrollLockHeight,
};
}); });
}; };
@ -841,6 +851,7 @@ export class Timeline extends React.Component<
} = this.props; } = this.props;
const { const {
scrollLocked, scrollLocked,
scrollLockHeight,
hasRecentlyScrolled, hasRecentlyScrolled,
lastMeasuredWarningHeight, lastMeasuredWarningHeight,
newestBottomVisibleMessageId, newestBottomVisibleMessageId,
@ -1142,6 +1153,11 @@ export class Timeline extends React.Component<
)} )}
ref={this.#messagesRef} ref={this.#messagesRef}
role="list" role="list"
style={
scrollLockHeight
? { flexBasis: scrollLockHeight }
: undefined
}
> >
{haveOldest && ( {haveOldest && (
<> <>