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

[FIX] spreadsheet: don't crash on right click #165183

Closed
wants to merge 1 commit into from
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
3 changes: 3 additions & 0 deletions addons/spreadsheet/static/src/pivot/pivot_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export const SEE_RECORDS_PIVOT = async (cell, env) => {
};

export const SEE_RECORDS_PIVOT_VISIBLE = (cell, env) => {
if (!cell) {
return false;
}
const { sheetId, col, row } = env.model.getters.getCellPosition(cell.id);
const pivotId = env.model.getters.getPivotIdFromPosition(sheetId, col, row);
if (!env.model.getters.isExistingPivot(pivotId)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { createSpreadsheetWithPivot } from "@spreadsheet/../tests/utils/pivot";
import spreadsheet from "@spreadsheet/o_spreadsheet/o_spreadsheet_extended";
import { registry } from "@web/core/registry";
import { setCellContent } from "../utils/commands";
import { getCell } from "../utils/getters";

const { cellMenuRegistry } = spreadsheet.registries;

Expand Down Expand Up @@ -117,3 +118,11 @@ QUnit.test(
assert.strictEqual(action.isVisible(env), true);
}
);

QUnit.test("See records is not visible on an empty cell", async function (assert) {
const { env, model } = await createSpreadsheetWithPivot();
assert.strictEqual(getCell(model, "A21"), undefined);
selectCell(model, "A21");
const action = cellMenuRegistry.getAll().find((item) => item.id === "pivot_see_records");
assert.strictEqual(action.isVisible(env), false);
});