mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 02:17:19 +00:00
inbox_ui: Fix scroll jump after initial render.
It is possible for us to scroll user back to top of view if they scroll before the render is complete and we haven't called `revive_current_focus` yet. This fixes it by wrapping the render and revive logic in a single animation frame so that any scroll requests are delayed until we have completed both of them.
This commit is contained in:
@@ -1168,6 +1168,9 @@ export function complete_rerender(): void {
|
||||
}
|
||||
load_data_from_ls();
|
||||
|
||||
// To avoid user scrolling before we have completed the rendering,
|
||||
// Wrap the rendering and position restoration in a requestAnimationFrame.
|
||||
requestAnimationFrame(() => {
|
||||
let first_filter: IteratorResult<string>;
|
||||
if (inbox_util.is_channel_view()) {
|
||||
const channel_id = inbox_util.get_channel_id();
|
||||
@@ -1221,10 +1224,8 @@ export function complete_rerender(): void {
|
||||
window.scrollTo(0, last_scroll_offset);
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
revive_current_focus();
|
||||
is_waiting_for_revive_current_focus = false;
|
||||
}, 0);
|
||||
|
||||
filters_dropdown_widget = new dropdown_widget.DropdownWidget({
|
||||
...views_util.COMMON_DROPDOWN_WIDGET_PARAMS,
|
||||
@@ -1235,6 +1236,7 @@ export function complete_rerender(): void {
|
||||
get_options: inbox_view_dropdown_options,
|
||||
});
|
||||
filters_dropdown_widget.setup();
|
||||
});
|
||||
}
|
||||
|
||||
export function search_and_update(): void {
|
||||
|
||||
Reference in New Issue
Block a user