Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FW][FIX] data_validation: prevent icon overlap #4150

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/components/data_validation_overlay/data_validation_overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ export class DataValidationOverlay extends Component<{}, SpreadsheetChildEnv> {
get checkBoxCellPositions(): CellPosition[] {
return this.env.model.getters
.getVisibleCellPositions()
.filter(this.env.model.getters.isCellValidCheckbox);
.filter(
(position) =>
this.env.model.getters.isCellValidCheckbox(position) &&
!this.env.model.getters.isFilterHeader(position)
);
}

get listIconsCellPositions(): CellPosition[] {
Expand All @@ -21,6 +25,10 @@ export class DataValidationOverlay extends Component<{}, SpreadsheetChildEnv> {
}
return this.env.model.getters
.getVisibleCellPositions()
.filter(this.env.model.getters.cellHasListDataValidationIcon);
.filter(
(position) =>
this.env.model.getters.cellHasListDataValidationIcon(position) &&
!this.env.model.getters.isFilterHeader(position)
);
}
}
17 changes: 16 additions & 1 deletion tests/data_validation/data_validation_checkbox_component.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { Model } from "../../src";
import { addDataValidation, setCellContent, setStyle } from "../test_helpers/commands_helpers";
import {
addDataValidation,
createFilter,
setCellContent,
setStyle,
} from "../test_helpers/commands_helpers";
import { getStyle } from "../test_helpers/getters_helpers";
import { mountSpreadsheet, nextTick } from "../test_helpers/helpers";
import { MockGridRenderingContext } from "../test_helpers/renderer_helpers";
Expand Down Expand Up @@ -81,4 +86,14 @@ describe("Checkbox component", () => {

expect(fixture.querySelector(".o-dv-checkbox")?.classList).toContain("pe-none");
});

test("Icon is not displayed if there is a filter icon", async () => {
const model = new Model();
addDataValidation(model, "A1", "id", { type: "isBoolean", values: [] });
createFilter(model, "A1:A4");

const { fixture } = await mountSpreadsheet({ model });
expect(fixture.querySelector(".o-dv-checkbox")).toBeNull();
expect(fixture.querySelector(".o-filter-icon")).not.toBeNull();
});
});
26 changes: 22 additions & 4 deletions tests/data_validation/data_validation_list_component.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import {
GRID_ICON_MARGIN,
} from "../../src/constants";
import { IsValueInListCriterion, UID } from "../../src/types";
import { addDataValidation, setCellContent, setSelection } from "../test_helpers/commands_helpers";
import {
addDataValidation,
createFilter,
setCellContent,
setSelection,
} from "../test_helpers/commands_helpers";
import { click, keyDown, setInputValueAndTrigger } from "../test_helpers/dom_helper";
import { getCellContent } from "../test_helpers/getters_helpers";
import {
Expand Down Expand Up @@ -329,17 +334,30 @@ describe("Selection arrow icon in grid", () => {
displayStyle: "plainText",
});
({ fixture } = await mountSpreadsheet({ model }));
expect(fixture.querySelector(".o-grid-cell-icon")).toBeNull();
expect(fixture.querySelector(".o-dv-list-icon")).toBeNull();
});

test("Icon is not displayed in dashboard", async () => {
model.updateMode("dashboard");
addDataValidation(model, "A1", "id", {
type: "isValueInList",
values: ["ok", "hello", "okay"],
displayStyle: "plainText",
displayStyle: "arrow",
});
({ fixture } = await mountSpreadsheet({ model }));
expect(fixture.querySelector(".o-dv-list-icon")).toBeNull();
});

test("Icon is not displayed if there is a filter icon", async () => {
addDataValidation(model, "A1", "id", {
type: "isValueInList",
values: ["ok", "hello", "okay"],
displayStyle: "arrow",
});
createFilter(model, "A1:A4");

({ fixture } = await mountSpreadsheet({ model }));
expect(fixture.querySelector(".o-grid-cell-icon")).toBeNull();
expect(fixture.querySelector(".o-dv-list-icon")).toBeNull();
expect(fixture.querySelector(".o-filter-icon")).not.toBeNull();
});
});