Skip to content

Commit 17f44f0

Browse files
committed
[FIX] carousel: missing color for empty carousel header
The header for an empty carousel with a title was missing a background color, making it transparent. closes #7177 Task: 5082459 X-original-commit: b1f21db Signed-off-by: Pierre Rousseau (pro) <pro@odoo.com>
1 parent 0f6ffc9 commit 17f44f0

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/components/figures/figure_carousel/figure_carousel.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ export class CarouselFigure extends Component<Props, SpreadsheetChildEnv> {
103103

104104
get headerStyle(): string {
105105
const cssProperties: CSSProperties = {};
106-
if (this.selectedCarouselItem?.type === "carouselDataView") {
107-
cssProperties["background-color"] = "#ffffff";
108-
} else if (this.selectedCarouselItem?.type === "chart") {
106+
if (this.selectedCarouselItem?.type === "chart") {
109107
const chart = this.env.model.getters.getChartRuntime(this.selectedCarouselItem.chartId);
110108
cssProperties["background-color"] = chart.background;
109+
} else {
110+
cssProperties["background-color"] = "#ffffff";
111111
}
112112
return cssPropertiesToCss(cssProperties);
113113
}

tests/figures/carousel/carousel_figure_component.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
createCarousel,
1010
createChart,
1111
paste,
12+
selectCarouselItem,
1213
updateCarousel,
1314
} from "../../test_helpers/commands_helpers";
1415
import { click, clickAndDrag, getElStyle, triggerMouseEvent } from "../../test_helpers/dom_helper";
@@ -164,6 +165,25 @@ describe("Carousel figure component", () => {
164165
expect(getElStyle(".o-figure .o-carousel-title", "font-weight")).toBe("bold");
165166
});
166167

168+
test("Carousel header has the correct background color", async () => {
169+
createCarousel(model, { items: [], title: { text: "Title" } }, "carouselId");
170+
await mountSpreadsheet({ model });
171+
172+
// Empty carousel
173+
expect(".o-carousel-header").toHaveStyle({ "background-color": "#FFFFFF" });
174+
175+
// Carousel with data view
176+
updateCarousel(model, "carouselId", { items: [{ type: "carouselDataView" }] });
177+
await nextTick();
178+
expect(".o-carousel-header").toHaveStyle({ "background-color": "#FFFFFF" });
179+
180+
// Carousel with chart
181+
const chartId = addNewChartToCarousel(model, "carouselId", { background: "#123456" });
182+
selectCarouselItem(model, "carouselId", { type: "chart", chartId });
183+
await nextTick();
184+
expect(".o-carousel-header").toHaveStyle({ "background-color": "#123456" });
185+
});
186+
167187
test("display chart menu", async () => {
168188
createCarousel(model, { items: [{ type: "carouselDataView" }] }, "carouselId");
169189
addNewChartToCarousel(model, "carouselId", { type: "bar" });

0 commit comments

Comments
 (0)