Skip to content

Commit

Permalink
FEATURE: add colId to popover grid context
Browse files Browse the repository at this point in the history
  • Loading branch information
matttdawson committed May 23, 2024
1 parent c995446 commit 97a4326
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/contexts/GridPopoverContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface GridPopoverContextType<TData extends GridBaseRow> {
anchorRef: RefObject<Element>;
saving: boolean;
setSaving: (saving: boolean) => void;
colId: string;
field: keyof TData;
value: any;
data: TData;
Expand All @@ -18,6 +19,7 @@ export const GridPopoverContext = createContext<GridPopoverContextType<any>>({
anchorRef: { current: null },
saving: false,
setSaving: () => {},
colId: "",
field: "",
value: null,
data: {} as GridBaseRow,
Expand Down
3 changes: 3 additions & 0 deletions src/contexts/GridPopoverContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ export const GridPopoverContextProvider = ({ props, children }: PropsWithChildre
multiEdit ? sortBy(getFilteredSelectedRows(), (row) => row.id !== props.data.id) : [props.data as GridBaseRow],
[getFilteredSelectedRows, multiEdit, props.data],
);

const field = props.colDef?.field ?? "";
const colId = props.colDef?.colId ?? field ?? "";

const updateValue = useCallback(
async (saveFn: (selectedRows: any[]) => Promise<boolean>, tabDirection: 1 | 0 | -1): Promise<boolean> => {
Expand All @@ -44,6 +46,7 @@ export const GridPopoverContextProvider = ({ props, children }: PropsWithChildre
saving,
setSaving,
selectedRows,
colId,
field,
data: props.data,
value: props.value,
Expand Down

0 comments on commit 97a4326

Please sign in to comment.