[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:
lfrb
2026-11-13 00:45:03 +00:00
committed by GitHub
co-authored by Tim Smart
parent 52701572e5
commit aa1471b4e3
3 changed files with 26 additions and 4 deletions
@@ -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.