mirror of
https://github.com/bitwarden/browser
synced 2026-02-14 07:23:45 +00:00
fix scroll positon after delete
This commit is contained in:
@@ -108,27 +108,6 @@ describe("VaultPopupScrollPositionService", () => {
|
||||
});
|
||||
expect((scrollElement as any).scrollTop).toBe(500);
|
||||
}));
|
||||
|
||||
it("forces scroll to top on next start when requested", fakeAsync(() => {
|
||||
service["scrollPosition"] = 500;
|
||||
|
||||
service.start(scrollElement);
|
||||
|
||||
tick();
|
||||
expect((scrollElement as any).scrollTo).toHaveBeenCalledWith({
|
||||
behavior: "instant",
|
||||
top: 0,
|
||||
});
|
||||
expect((scrollElement as any).scrollTop).toBe(0);
|
||||
|
||||
// A follow-up scroll is scheduled to defeat Firefox scroll restoration.
|
||||
((scrollElement as any).scrollTo as jest.Mock).mockClear();
|
||||
tick(300);
|
||||
expect((scrollElement as any).scrollTo).toHaveBeenCalledWith({
|
||||
behavior: "instant",
|
||||
top: 0,
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
describe("scroll listener", () => {
|
||||
|
||||
@@ -31,9 +31,12 @@ export class VaultPopupScrollPositionService {
|
||||
|
||||
/** Scrolls the user to the stored scroll position and starts tracking scroll of the page. */
|
||||
start(scrollElement: HTMLElement) {
|
||||
setTimeout(() => {
|
||||
scrollElement.scrollTo({ top: this.scrollPosition!, behavior: "instant" });
|
||||
});
|
||||
if (this.hasScrollPosition()) {
|
||||
// Use `setTimeout` to scroll after rendering is complete
|
||||
setTimeout(() => {
|
||||
scrollElement.scrollTo({ top: this.scrollPosition, behavior: "instant" });
|
||||
});
|
||||
}
|
||||
|
||||
this.scrollSubscription?.unsubscribe();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user