diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php index 8219b8b135330..83b021f04d185 100644 --- a/apps/theming/lib/ThemingDefaults.php +++ b/apps/theming/lib/ThemingDefaults.php @@ -231,10 +231,10 @@ public function getColorPrimary(): string { $themingBackground = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'background', ''); // If the user selected the default background if ($themingBackground === '') { - return BackgroundService::DEFAULT_COLOR; + return $defaultColor; } - // If the user selected a specific colour + // If the user selected a valid custom colour if (preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $themingBackground)) { return $themingBackground; } @@ -245,11 +245,6 @@ public function getColorPrimary(): string { } } - // If the default color is not valid, return the default background one - if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $defaultColor)) { - return BackgroundService::DEFAULT_COLOR; - } - // Finally, return the system global primary color return $defaultColor; } @@ -259,9 +254,12 @@ public function getColorPrimary(): string { */ public function getDefaultColorPrimary(): string { $color = $this->config->getAppValue(Application::APP_ID, 'color'); + + // If the color is invalid, fallback to default if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $color)) { - $color = '#0082c9'; + $color = BackgroundService::DEFAULT_COLOR; } + return $color; } diff --git a/tests/acceptance/features/app-theming.feature b/tests/acceptance/features/app-theming.feature index 7b734f7f3183b..9744cc49eda1d 100644 --- a/tests/acceptance/features/app-theming.feature +++ b/tests/acceptance/features/app-theming.feature @@ -13,7 +13,8 @@ Feature: app-theming And I see that the non-plain background color variable is eventually "#0082c9" When I set the "Color" parameter in the Theming app to "#C9C9C9" Then I see that the parameters in the Theming app are eventually saved - And I see that the primary color is eventually "#006aa3" + # Default user background follows admin theming + And I see that the primary color is eventually "#C9C9C9" And I see that the non-plain background color variable is eventually "#C9C9C9" Scenario: resetting the color updates the primary color @@ -23,9 +24,10 @@ Feature: app-theming And I see that the color selector in the Theming app has loaded And I set the "Color" parameter in the Theming app to "#C9C9C9" And I see that the parameters in the Theming app are eventually saved - And I see that the primary color is eventually "#006aa3" + And I see that the primary color is eventually "#C9C9C9" And I see that the non-plain background color variable is eventually "#C9C9C9" When I reset the "Color" parameter in the Theming app to its default value Then I see that the parameters in the Theming app are eventually saved + # Default user background follows admin theming And I see that the primary color is eventually "#006aa3" And I see that the non-plain background color variable is eventually "#0082c9"