Skip to content

Commit ebb8c95

Browse files
committed
[FIX] full_screen_chart: prevent fullscreen chart from closing on drag-out
Steps to reproduce: 1. Open a dashboard and put a chart in fullscreen. 2. mousedown inside the chart. 3. Drag the pointer outside the chart window. 4. Release (mouseup). Before this commit: The fullscreen closes unexpectedly. Because mousedown and mouseup occur on different elements, the browser dispatches the click on their nearest common ancestor (the overlay), which had the close handler. After this commit: - Introduce a dedicated `.o-fullscreen-chart-backdrop` sibling and move the close handler there. - Result: drag-out (down in chart, up outside) no longer closes; outside click (down+up on backdrop), Exit button, and `Esc` still close as expected. closes #6991 Task: 5005933 Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
1 parent 1ee2018 commit ebb8c95

File tree

3 files changed

+41
-6
lines changed

3 files changed

+41
-6
lines changed

src/components/full_screen_chart/full_screen_chart.xml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<templates>
22
<t t-name="o-spreadsheet-FullScreenChart">
3-
<div
4-
class="position-absolute o-fullscreen-chart-overlay w-100 h-100 d-flex"
5-
t-if="figureUI"
6-
t-on-click="exitFullScreen">
3+
<div class="position-absolute o-fullscreen-chart-overlay w-100 h-100 d-flex" t-if="figureUI">
4+
<div
5+
class="position-absolute top-0 start-0 end-0 bottom-0"
6+
t-on-click="exitFullScreen"
7+
aria-hidden="true"
8+
/>
79
<button
810
class="o-exit top-0 end-0 position-absolute o-button primary m-1"
911
t-on-click="exitFullScreen">

tests/figures/chart/chart_full_screen.test.ts

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import { Model } from "../../../src";
22
import { createScorecardChart, createWaterfallChart } from "../../test_helpers/commands_helpers";
3-
import { click, keyDown } from "../../test_helpers/dom_helper";
3+
import {
4+
click,
5+
keyDown,
6+
pointerDown,
7+
pointerUp,
8+
triggerMouseEvent,
9+
} from "../../test_helpers/dom_helper";
410
import { mockChart, mountSpreadsheet, nextTick } from "../../test_helpers/helpers";
511

612
mockChart();
@@ -47,7 +53,7 @@ describe("chart menu for dashboard", () => {
4753
// Click outside of the chart in the full screen overlay
4854
await click(fixture, ".o-figure [data-id='fullScreenChart']");
4955
expect(".o-fullscreen-chart").toHaveCount(1);
50-
await click(fixture, ".o-fullscreen-chart-overlay");
56+
await click(fixture, ".o-fullscreen-chart-overlay > div:first-child");
5157
expect(".o-fullscreen-chart").toHaveCount(0);
5258

5359
// Click the exit button in the full screen overlay
@@ -62,4 +68,26 @@ describe("chart menu for dashboard", () => {
6268
await keyDown({ key: "Escape" });
6369
expect(".o-fullscreen-chart").toHaveCount(0);
6470
});
71+
72+
test("Keeps fullscreen open when pointerdown is inside and pointerup is outside", async () => {
73+
createWaterfallChart(model);
74+
model.updateMode("dashboard");
75+
await nextTick();
76+
77+
await click(fixture, ".o-figure [data-id='fullScreenChart']");
78+
expect(".o-fullscreen-chart").toHaveCount(1);
79+
80+
const chart = fixture.querySelector(".o-fullscreen-chart")!;
81+
const overlay = fixture.querySelector(".o-fullscreen-chart-overlay")!;
82+
expect(chart).not.toBeNull();
83+
expect(overlay).not.toBeNull();
84+
85+
await pointerDown(chart);
86+
await pointerUp(overlay);
87+
88+
triggerMouseEvent(overlay, "click");
89+
await nextTick();
90+
91+
expect(".o-fullscreen-chart").toHaveCount(1);
92+
});
6593
});

tests/test_helpers/dom_helper.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ export async function pointerDown(target: DOMTarget) {
121121
await nextTick();
122122
}
123123

124+
export async function pointerUp(target: DOMTarget) {
125+
triggerMouseEvent(target, "pointerup");
126+
await nextTick();
127+
}
128+
124129
/**
125130
* Simulate hovering a cell for a given amount of time.
126131
* Don't forget to use `jest.useFakeTimers();` when using

0 commit comments

Comments
 (0)