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

table col width #2358

Merged
merged 5 commits into from
Dec 20, 2024
Merged
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
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
Loading