Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
Cursor on table (non edit mode) (#974)
Browse files Browse the repository at this point in the history
* Cursor on table (non edit mode) (#971)

* fx tests

* fx tests

---------

Co-authored-by: Fred Lefévère-Laoide <[email protected]>
  • Loading branch information
FredLL-Avaiga and Fred Lefévère-Laoide authored Oct 13, 2023
1 parent 442001a commit 41cab80
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
6 changes: 3 additions & 3 deletions gui/src/components/Taipy/AutoLoadingTable.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ describe("AutoLoadingTable Component", () => {
);
const elts = getAllByText("Austria");
expect(elts.length).toBeGreaterThan(1);
expect(elts[0].tagName).toBe("DIV");
expect(elts[0].tagName).toBe("SPAN");
});
it("selects the rows", async () => {
const dispatch = jest.fn();
Expand All @@ -238,8 +238,8 @@ describe("AutoLoadingTable Component", () => {
const elts = getAllByText("Austria");
elts.forEach((elt: HTMLElement, idx: number) =>
selected.indexOf(idx) == -1
? expect(elt.parentElement?.parentElement).not.toHaveClass("Mui-selected")
: expect(elt.parentElement?.parentElement).toHaveClass("Mui-selected")
? expect(elt.parentElement?.parentElement?.parentElement).not.toHaveClass("Mui-selected")
: expect(elt.parentElement?.parentElement?.parentElement).toHaveClass("Mui-selected")
);
expect(document.querySelectorAll(".Mui-selected")).toHaveLength(selected.length);
});
Expand Down
6 changes: 3 additions & 3 deletions gui/src/components/Taipy/PaginatedTable.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ describe("PaginatedTable Component", () => {
);
const elts = getAllByText("Austria");
expect(elts.length).toBeGreaterThan(1);
expect(elts[0].tagName).toBe("DIV");
expect(elts[0].tagName).toBe("SPAN");
});
it("selects the rows", async () => {
const dispatch = jest.fn();
Expand All @@ -299,8 +299,8 @@ describe("PaginatedTable Component", () => {
const elts = await waitFor(() => findAllByText("Austria"));
elts.forEach((elt: HTMLElement, idx: number) =>
selected.indexOf(idx) == -1
? expect(elt.parentElement?.parentElement).not.toHaveClass("Mui-selected")
: expect(elt.parentElement?.parentElement).toHaveClass("Mui-selected")
? expect(elt.parentElement?.parentElement?.parentElement).not.toHaveClass("Mui-selected")
: expect(elt.parentElement?.parentElement?.parentElement).toHaveClass("Mui-selected")
);
expect(document.querySelectorAll(".Mui-selected")).toHaveLength(selected.length);
});
Expand Down
7 changes: 5 additions & 2 deletions gui/src/components/Taipy/tableUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,14 @@ const VALID_BOOLEAN_STRINGS = ["true", "1", "t", "y", "yes", "yeah", "sure"];
const isBooleanTrue = (val: RowValue) =>
typeof val == "string" ? VALID_BOOLEAN_STRINGS.some((s) => s == val.trim().toLowerCase()) : !!val;

const defaultCursor = { cursor: "default" };
const defaultCursorIcon = { ...iconInRowSx, "& .MuiSwitch-input": defaultCursor };

const renderCellValue = (val: RowValue | boolean, col: ColumnDesc, formatConf: FormatConfig, nanValue?: string) => {
if (val !== null && val !== undefined && col.type && col.type.startsWith("bool")) {
return <Switch checked={val as boolean} size="small" title={val ? "True" : "False"} sx={iconInRowSx} />;
return <Switch checked={val as boolean} size="small" title={val ? "True" : "False"} sx={defaultCursorIcon} />;
}
return <>{formatValue(val as RowValue, col, formatConf, nanValue)}</>;
return <span style={defaultCursor}>{formatValue(val as RowValue, col, formatConf, nanValue)}</span>;
};

const getCellProps = (col: ColumnDesc, base: Partial<TableCellProps> = {}): Partial<TableCellProps> => {
Expand Down

0 comments on commit 41cab80

Please sign in to comment.