Skip to content

Commit

Permalink
table col width
Browse files Browse the repository at this point in the history
resolves #2286
  • Loading branch information
Fred Lefévère-Laoide authored and Fred Lefévère-Laoide committed Dec 19, 2024
1 parent 11ff277 commit 6e5d024
Show file tree
Hide file tree
Showing 9 changed files with 240 additions and 139 deletions.
2 changes: 2 additions & 0 deletions frontend/taipy-gui/packaging/taipy-gui.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,8 @@ export interface ColumnDesc {
lov?: string[];
/** If true the user can enter any value besides the lov values. */
freeLov?: boolean;
/** If true, the column cannot be sorted */
notSortable?: boolean;
}
/**
* A cell value type.
Expand Down
11 changes: 11 additions & 0 deletions frontend/taipy-gui/src/components/Taipy/AutoLoadingTable.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const tableValue = {
},
};
const tableColumns = JSON.stringify({ Entity: { dfid: "Entity" } });
const tableWidthColumns = JSON.stringify({ Entity: { dfid: "Entity", width: "100px" }, Country: {dfid: "Country"} });

describe("AutoLoadingTable Component", () => {
it("renders", async () => {
Expand Down Expand Up @@ -132,6 +133,16 @@ describe("AutoLoadingTable Component", () => {
const { queryByTestId } = render(<AutoLoadingTable data={undefined} defaultColumns={tableColumns} active={false} />);
expect(queryByTestId("ArrowDownwardIcon")).toBeNull();
});
it("hides sort icons when not sortable", async () => {
const { queryByTestId } = render(<AutoLoadingTable data={undefined} defaultColumns={tableColumns} sortable={false} />);
expect(queryByTestId("ArrowDownwardIcon")).toBeNull();
});
it("set width if requested", async () => {
const { getByText } = render(<AutoLoadingTable data={undefined} defaultColumns={tableWidthColumns} />);
const header = getByText("Entity").closest("tr");
expect(header?.firstChild).toHaveStyle({"min-width": "100px"});
expect(header?.lastChild).toHaveStyle({"width": "100%"});
});
// keep getting undefined Error from jest, it seems to be linked to the setTimeout that makes the code run after the end of the test :-(
// https://github.com/facebook/jest/issues/12262
// Looks like the right way to handle this is to use jest fakeTimers and runAllTimers ...
Expand Down
Loading

0 comments on commit 6e5d024

Please sign in to comment.