mirror of
https://github.com/actualbudget/actual.git
synced 2026-11-16 14:56:16 -06:00
[AI] fix: prevent background loader flicker (#9523)
* [AI] fix: prevent background loader flicker Keep the lazy importer stable across renders so LoadComponent does not unload and reload the background when its parent rerenders. * docs: clarify background flicker release note * test: assert background artwork identity synchronously --------- Co-authored-by: Tim Smart <hello@timsmart.co>
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { expect, it, vi } from 'vitest';
|
||||
|
||||
import { Background } from './Background';
|
||||
|
||||
vi.mock('./BackgroundImage', () => ({
|
||||
BackgroundImage: () => <g data-testid="background-artwork" />,
|
||||
}));
|
||||
|
||||
it('keeps the background artwork mounted when its parent rerenders', async () => {
|
||||
const { rerender } = render(<Background />);
|
||||
const artwork = await screen.findByTestId('background-artwork');
|
||||
|
||||
rerender(<Background />);
|
||||
|
||||
expect(screen.getByTestId('background-artwork')).toBe(artwork);
|
||||
});
|
||||
@@ -4,6 +4,8 @@ import { theme } from '@actual-app/components/theme';
|
||||
|
||||
import { LoadComponent } from './util/LoadComponent';
|
||||
|
||||
const loadBackgroundImage = () => import('./BackgroundImage');
|
||||
|
||||
export function Background() {
|
||||
return (
|
||||
<div
|
||||
@@ -47,10 +49,7 @@ export function Background() {
|
||||
/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<LoadComponent
|
||||
importer={() => import('./BackgroundImage')}
|
||||
name="BackgroundImage"
|
||||
/>
|
||||
<LoadComponent importer={loadBackgroundImage} name="BackgroundImage" />
|
||||
</svg>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
category: Bugfix
|
||||
authors: [lfrb]
|
||||
---
|
||||
|
||||
Prevent the background artwork from flickering during updates.
|
||||
Reference in New Issue
Block a user