Skip to content

Commit

Permalink
table col width (#2358)
Browse files Browse the repository at this point in the history
* table col width
resolves #2286

* Fab's comment

Co-authored-by: Fabien Lelaquais <[email protected]>

* notSortable => sortable

* Fab's comment

Co-authored-by: Fabien Lelaquais <[email protected]>

---------

Co-authored-by: Fred Lefévère-Laoide <[email protected]>
Co-authored-by: Fabien Lelaquais <[email protected]>
  • Loading branch information
3 people authored Dec 20, 2024
1 parent 5a4b3f8 commit 13d97c5
Show file tree
Hide file tree
Showing 9 changed files with 245 additions and 140 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 false, the column cannot be sorted */
sortable?: 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 13d97c5

Please sign in to comment.