A local-first personal finance app
[AI] Prevent custom CSS indicator overlap in theme settings (#8896) (#8910)
Felipe Medicieb28966d6ca5
diff --git a/packages/desktop-client/e2e/settings.test.ts b/packages/desktop-client/e2e/settings.test.tsindex 411a0e1453..e4fceabcaa 100644--- a/packages/desktop-client/e2e/settings.test.ts+++ b/packages/desktop-client/e2e/settings.test.ts@@ -39,4 +39,83 @@ test.describe('Settings', () => {expect(download.suggestedFilename()).toMatch(/^\d{4}-\d{2}-\d{2}-.*.zip$/);});++ test('keeps the global CSS override readable after switching themes', async () => {+ await page.setViewportSize({ width: 1024, height: 900 });+ await page.route('**/customThemeCatalog.json', route =>+ route.fulfill({+ json: [{ name: 'Test theme', repo: 'test/theme', mode: 'light' }],+ }),+ );+ await page.route('**/test/theme/refs/heads/main/actual.css*', route =>+ route.fulfill({ body: ':root { --color-pageBackground: #eeeeee; }' }),+ );+ await page.evaluate(() => window.Actual.setTheme('light'));+ await page.getByRole('button', { name: 'Light', exact: true }).click();+ await page+ .getByRole('button', { name: 'Custom theme', exact: true })+ .click();+ await page.getByRole('button', { name: 'Test theme', exact: true }).click();+ const css = ':root { --color-pageBackground: #abcdef; }';+ await page.getByRole('textbox', { name: 'Custom Theme CSS' }).fill(css);+ await page.getByRole('button', { name: 'Apply', exact: true }).click();+ await page.getByRole('button', { name: 'Close', exact: true }).click();++ const indicator = page.getByRole('button', {+ name: 'Custom CSS override active — click to edit',+ });+ let currentTheme = 'Test theme';+ for (const nextTheme of ['Dark', 'Midnight', 'Light', 'System default']) {+ await page+ .getByRole('button', { name: currentTheme, exact: true })+ .click();+ await page.getByRole('button', { name: nextTheme, exact: true }).click();+ await expect(indicator).toBeVisible();+ await expect+ .poll(() =>+ page.evaluate(() =>+ getComputedStyle(document.documentElement)+ .getPropertyValue('--color-pageBackground')+ .trim(),+ ),+ )+ .toBe('#abcdef');+ currentTheme = nextTheme;+ }++ for (const width of [1024, 800, 375]) {+ await page.setViewportSize({ width, height: 900 });+ if (width === 375) {+ await expect(page.getByRole('navigation')).toBeVisible();+ }+ await indicator.scrollIntoViewIfNeeded();+ await page.screenshot({+ path: test.info().outputPath(`system-default-${width}.png`),+ });+ const indicatorBounds = await indicator.boundingBox();+ const lightBounds = await page+ .getByRole('button', { name: 'Light', exact: true })+ .boundingBox();+ if (!indicatorBounds || !lightBounds) {+ throw new Error('Missing theme controls');+ }+ const overlapsLightSelector =+ indicatorBounds.x < lightBounds.x + lightBounds.width &&+ indicatorBounds.x + indicatorBounds.width > lightBounds.x &&+ indicatorBounds.y < lightBounds.y + lightBounds.height &&+ indicatorBounds.y + indicatorBounds.height > lightBounds.y;+ expect(overlapsLightSelector).toBe(false);+ await expect(indicator).toBeInViewport();+ }+ await indicator.focus();+ await page.keyboard.press('Enter');+ await expect(+ page.getByRole('textbox', { name: 'Custom Theme CSS' }),+ ).toHaveValue(css);+ await page.getByRole('textbox', { name: 'Custom Theme CSS' }).fill('');+ await page.getByRole('button', { name: 'Apply', exact: true }).click();+ await page.getByRole('button', { name: 'Close', exact: true }).click();+ await expect(indicator).toBeHidden();+ await expect(page.locator('#custom-theme-active')).toHaveCount(0);+ });});diff --git a/packages/desktop-client/src/components/settings/Themes.tsx b/packages/desktop-client/src/components/settings/Themes.tsxindex 0178115e27..ec2ecb4735 100644--- a/packages/desktop-client/src/components/settings/Themes.tsx+++ b/packages/desktop-client/src/components/settings/Themes.tsx@@ -218,41 +218,17 @@ export function ThemeSettings() {}}><Column title={t('Theme')}>- <View- style={{- flexDirection: 'row',- alignItems: 'center',- gap: 8,- }}- >- <Select<string>- onChange={handleThemeChange}- value={getCurrentValue()}- options={buildOptions()}- className={css({- '&[data-hovered]': {- backgroundColor: themeStyle.buttonNormalBackgroundHover,- },- maxWidth: '100%',- })}- />- {hasCustomCssOverride && (- <Button- variant="bare"- aria-label={t(- 'Custom CSS override active — click to edit',- )}- onPress={handleEditOverride}- style={{- color: themeStyle.pageTextPositive,- gap: 6,- }}- >- <Trans>Custom CSS is active</Trans>- <SvgCode style={{ width: 14, height: 14 }} />- </Button>- )}- </View>+ <Select<string>+ onChange={handleThemeChange}+ value={getCurrentValue()}+ options={buildOptions()}+ className={css({+ '&[data-hovered]': {+ backgroundColor: themeStyle.buttonNormalBackgroundHover,+ },+ maxWidth: '100%',+ })}+ /></Column>{theme === 'auto' && (<>@@ -297,6 +273,22 @@ export function ThemeSettings() {</View>)}+ {!showInstaller && hasCustomCssOverride && (+ <Button+ variant="bare"+ aria-label={t('Custom CSS override active — click to edit')}+ onPress={handleEditOverride}+ style={{+ alignSelf: 'flex-start',+ color: themeStyle.pageTextPositive,+ gap: 6,+ }}+ >+ <Trans>Custom CSS is active</Trans>+ <SvgCode style={{ width: 14, height: 14 }} />+ </Button>+ )}+{showInstaller && (<ThemeInstalleronInstall={handleInstall}diff --git a/packages/docs/docs/custom-themes.md b/packages/docs/docs/custom-themes.mdindex 5b804c2f9a..44b396036a 100644--- a/packages/docs/docs/custom-themes.md+++ b/packages/docs/docs/custom-themes.md@@ -15,16 +15,20 @@ The easiest way to install a custom theme is to choose one from the catalog:Themes in the catalog are hosted on GitHub and are automatically fetched when you select them. Each theme shows a color palette preview (6 colors in a 3x2 grid) and includes a link to its source repository.-### Installing a Theme by Pasting CSS+### Applying Custom CSS Overrides-You can also install a custom theme by pasting CSS directly:+You can also customize your colors by pasting CSS directly:1. Go to **Settings** → **Themes** → **Custom theme**-2. Scroll down to the "or paste CSS directly" section+2. Scroll down to the **Additional CSS overrides** section3. Paste your theme CSS into the text area4. Click **Apply**-The CSS will be validated before installation. If there are any errors, they will be displayed below the text area.+The CSS will be validated before it is applied. If there are any errors, they will be displayed below the text area.++These overrides apply on top of every theme, including **Light**, **Dark**, **Midnight**, and both modes of **System default**. Switching themes does not clear your overrides.++The **Custom CSS is active** button below the theme selectors opens the editor with your saved CSS. To remove the overrides, clear the text area and click **Apply**.## Publishing Custom Themesdiff --git a/upcoming-release-notes/fix-custom-css-indicator-layout.md b/upcoming-release-notes/fix-custom-css-indicator-layout.mdnew file mode 100644index 0000000000..60c4a9d747--- /dev/null+++ b/upcoming-release-notes/fix-custom-css-indicator-layout.md@@ -0,0 +1,6 @@+---+category: Bugfix+authors: [femedici]+---++Prevent the custom CSS indicator from overlapping theme selectors when using System default.