Skip to content

Commit

Permalink
[FIX] PivotDimension: Prevent DnD on dimension action buttons
Browse files Browse the repository at this point in the history
If we apply a mouse down on the action buttons of a pivot dimension
(e.g. on the trash or hide/show icon) and move of a single pixel,
the drag-n-drop of the dimension is triggered, which prevents the
default action of the said action button.

This commit also prevents this behaviour when targeting the standalone
composer of the computed measures.

closes #5227

Task: 4095643
X-original-commit: 270308d
Signed-off-by: Lucas Lefèvre (lul) <[email protected]>
Signed-off-by: Rémi Rahir (rar) <[email protected]>
  • Loading branch information
rrahir committed Nov 19, 2024
1 parent 5222d9a commit 1850991
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/>
<span t-else="1" class="o-fw-bold" t-esc="props.dimension.displayName"/>
</div>
<div class="d-flex flex-rows">
<div class="d-flex flex-rows" t-on-pointerdown.stop="">
<t t-slot="upper-right-icons"/>
<i
class="o-button-icon fa fa-trash pe-1 ps-2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/>
</t>
<div t-if="measure.computedBy" class="d-flex flex-row small">
<div class="d-flex flex-column py-2 px-2 w-100">
<div class="d-flex flex-column py-2 px-2 w-100" t-on-pointerdown.stop="">
<StandaloneComposer
onConfirm.bind="updateMeasureFormula"
composerContent="measure.computedBy.formula"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,4 +561,34 @@ describe("Spreadsheet pivot side panel", () => {
{ id: "amount:sum", fieldName: "amount", aggregator: "sum", isHidden: false },
]);
});

test("Cannot drag a dimension when clicking its upper right icons", async () => {
mockGetBoundingClientRect({
/**
* 'pt-1' is the class of the main div of the pivot dimension
*/
"pt-1": () => ({
height: 10,
y: 0,
}),
"o-section-title": () => ({
height: 10,
y: 10,
}),
"pivot-dimensions": () => ({
height: 40,
y: 0,
}),
});
await click(fixture.querySelector(".add-dimension")!);
await click(fixture.querySelectorAll(".o-autocomplete-value")[0]);
await setInputValueAndTrigger(fixture.querySelector(".pivot-dimension select"), "desc");
expect(model.getters.getPivotCoreDefinition("1").columns).toEqual([
{ fieldName: "Amount", order: "desc" },
]);
await dragElement(".pivot-dimension .fa-trash", { x: 0, y: 30 }, undefined, true);
expect(model.getters.getPivotCoreDefinition("1").columns).toEqual([
{ fieldName: "Amount", order: "desc" },
]);
});
});

0 comments on commit 1850991

Please sign in to comment.