From aa1471b4e34ea6a7b716cd29ff43cbb0e8ac0137 Mon Sep 17 00:00:00 2001 From: lfrb Date: Fri, 13 Nov 2026 00:45:03 +0000 Subject: [PATCH] [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 --- .../src/components/Background.test.tsx | 17 +++++++++++++++++ .../src/components/Background.tsx | 7 +++---- .../background-loader-flicker.md | 6 ++++++ 3 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 packages/desktop-client/src/components/Background.test.tsx create mode 100644 upcoming-release-notes/background-loader-flicker.md diff --git a/packages/desktop-client/src/components/Background.test.tsx b/packages/desktop-client/src/components/Background.test.tsx new file mode 100644 index 0000000000..3e826646b3 --- /dev/null +++ b/packages/desktop-client/src/components/Background.test.tsx @@ -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: () => , +})); + +it('keeps the background artwork mounted when its parent rerenders', async () => { + const { rerender } = render(); + const artwork = await screen.findByTestId('background-artwork'); + + rerender(); + + expect(screen.getByTestId('background-artwork')).toBe(artwork); +}); diff --git a/packages/desktop-client/src/components/Background.tsx b/packages/desktop-client/src/components/Background.tsx index 4d7bc3498e..0750482a01 100644 --- a/packages/desktop-client/src/components/Background.tsx +++ b/packages/desktop-client/src/components/Background.tsx @@ -4,6 +4,8 @@ import { theme } from '@actual-app/components/theme'; import { LoadComponent } from './util/LoadComponent'; +const loadBackgroundImage = () => import('./BackgroundImage'); + export function Background() { return (
- import('./BackgroundImage')} - name="BackgroundImage" - /> +
); diff --git a/upcoming-release-notes/background-loader-flicker.md b/upcoming-release-notes/background-loader-flicker.md new file mode 100644 index 0000000000..e60c0d1376 --- /dev/null +++ b/upcoming-release-notes/background-loader-flicker.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [lfrb] +--- + +Prevent the background artwork from flickering during updates.