-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: updated collapsable rows for grouped rows and expansion state t…
…oggle (#302)
- Loading branch information
Fran McDade
authored and
Fran McDade
committed
Jan 2, 2025
1 parent
55adf3d
commit ed6b088
Showing
10 changed files
with
63 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 19 additions & 2 deletions
21
src/components/Table/components/TableRow/tableRow.styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/components/Table/components/TableRows/components/CollapsableRows/hook.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { RowData, Table } from "@tanstack/react-table"; | ||
import { useEffect } from "react"; | ||
|
||
/** | ||
* Hook to manage the expanded row state during viewport transitions (e.g., desktop to mobile and vice versa). | ||
* Designed for use with the `CollapsableRows` component, where row expansion is a work in progress for desktop viewports. | ||
* This hook ensures that all rows are collapsed when transitioning from desktop to mobile (when `CollapsableRows` component is mounted). | ||
* It also resets the expanded row state when transitioning back to desktop (when the `CollapsableRows` component is unmounted). | ||
* @param table - Table. | ||
*/ | ||
export function useCollapsableRows<T extends RowData>(table: Table<T>): void { | ||
const { resetExpanded, toggleAllRowsExpanded } = table; | ||
|
||
useEffect(() => { | ||
toggleAllRowsExpanded(false); | ||
return (): void => { | ||
resetExpanded(); | ||
}; | ||
}, [resetExpanded, toggleAllRowsExpanded]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters