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

Fix for #410 #412

Merged
merged 5 commits into from
Dec 5, 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
16 changes: 12 additions & 4 deletions src/management-system-v2/components/process-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
SetStateAction,
Key,
ReactElement,
useEffect,
useState,
} from 'react';
import {
CopyOutlined,
Expand All @@ -35,6 +37,7 @@ import FavouriteStar from './favouriteStar';
import { contextMenuStore } from './processes/context-menu';
import { DraggableElementGenerator } from './processes/draggable-element';
import classNames from 'classnames';
import { set } from 'zod';

/** respects sorting function, but always keeps folders at the beginning */
function folderAwareSort(sortFunction: (a: ProcessListProcess, b: ProcessListProcess) => number) {
Expand Down Expand Up @@ -400,6 +403,14 @@ const ProcessManagementList: FC<ProcessManagementListProps> = ({
const setContextMenuItem = contextMenuStore((store) => store.setSelected);
const metaPanelisOpened = useUserPreferences.use['process-meta-data']().open;

const [scrollY, setScrollY] = useState('400px');
useEffect(() => {
if (window)
setScrollY(
`${window.innerHeight - 32 /* Footer */ - 64 /* Header */ - 82 /* Table-Search etc */ - 60 /* Table-head */ - 60 /* Table-Footer / Pagination */}px`,
);
}, []);

return (
<BaseProcessList
data={data}
Expand All @@ -410,10 +421,7 @@ const ProcessManagementList: FC<ProcessManagementListProps> = ({
processActions={processActions}
tableProps={{
scroll: {
y:
typeof window !== 'undefined' && window.innerHeight > 0
? `${window?.innerHeight - 32 /* Footer */ - 64 /* Header */ - 82 /* Table-Search etc */ - 60 /* Table-head */ - 60 /* Table-Footer / Pagination */}px`
: undefined,
y: scrollY,
},
pagination: { position: ['bottomCenter'], pageSize: 20 },
onRow: (item) => ({
Expand Down
6 changes: 3 additions & 3 deletions src/management-system-v2/lib/useColumnWidth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const useResizeableColumnWidth = (
const initialisedWithHydratedValues =
useRef(
false,
); /* Basically a switch to check whther the state was updated once with the saved values, once hydrated */
); /* Basically a switch to check whether the state was updated once with the saved values, once hydrated */
const convertedWidthsToNumbers = useRef(false); /* Similar switch */

const computeNewColumns = useCallback(() => {
Expand Down Expand Up @@ -58,13 +58,13 @@ export const useResizeableColumnWidth = (
initialisedWithHydratedValues.current = true;
// console.debug('Updated columns with hydrated values');
setResizeableColumns(newColumns);
}, [hydrated, computeNewColumns, initialisedWithHydratedValues.current]);
}, [hydrated, computeNewColumns]);

/* If the user selects different columns (i.e. columnsInPreferences change) update the state with new columns */
useEffect(() => {
if (!hydrated) return;

/* This should onl run if the length of the arrays is dfferent */
/* This should only run if the length of the arrays is dfferent */
if (columnsInPreferences.length === resizeableColumns.length) return;

const newColumns = computeNewColumns();
Expand Down
Loading