diff --git a/src/components/Table/ContextMenu/MenuContents.tsx b/src/components/Table/ContextMenu/MenuContents.tsx index 0870409ea..1e4cf4253 100644 --- a/src/components/Table/ContextMenu/MenuContents.tsx +++ b/src/components/Table/ContextMenu/MenuContents.tsx @@ -141,6 +141,34 @@ export default function MenuContents({ onClose }: IMenuContentsProps) { }); } }; + + const handleClearValue = () => { + const clearValue = () => { + updateField({ + path: selectedCell.path, + fieldName: selectedColumn.fieldName, + arrayTableData: { + index: selectedCell.arrayIndex, + }, + value: null, + deleteField: true, + }); + onClose(); + }; + + if (altPress || row._rowy_ref.arrayTableData !== undefined) { + clearValue(); + } else { + confirm({ + title: "Clear cell value?", + body: "The cell’s value cannot be recovered after", + confirm: "Delete", + confirmColor: "error", + handleConfirm: clearValue, + }); + } + }; + const rowActions: IContextMenuItem[] = [ { label: "Copy ID", @@ -214,13 +242,7 @@ export default function MenuContents({ onClose }: IMenuContentsProps) { // Cell actions // TODO: Add copy and paste here const cellValue = row?.[selectedCell.columnKey]; - const handleClearValue = () => - updateField({ - path: selectedCell.path, - fieldName: selectedColumn.fieldName, - value: null, - deleteField: true, - }); + const columnFilters = getFieldProp( "filter", selectedColumn?.type === FieldType.derivative @@ -247,18 +269,7 @@ export default function MenuContents({ onClose }: IMenuContentsProps) { !row || cellValue === undefined || getFieldProp("group", selectedColumn?.type) === "Auditing", - onClick: altPress - ? handleClearValue - : () => { - confirm({ - title: "Clear cell value?", - body: "The cell’s value cannot be recovered after", - confirm: "Delete", - confirmColor: "error", - handleConfirm: handleClearValue, - }); - onClose(); - }, + onClick: handleClearValue, }, { label: "Filter value", diff --git a/src/hooks/useFirestoreDocAsCollectionWithAtom.ts b/src/hooks/useFirestoreDocAsCollectionWithAtom.ts index 1d0499a0c..9d2045446 100644 --- a/src/hooks/useFirestoreDocAsCollectionWithAtom.ts +++ b/src/hooks/useFirestoreDocAsCollectionWithAtom.ts @@ -201,7 +201,7 @@ export function useFirestoreDocAsCollectionWithAtom( useEffect(() => { if (deleteDocAtom) { setDeleteRowAtom(() => (_: string, options?: ArrayTableRowData) => { - if (!options || !options.index) return; + if (!options || options.index === undefined) return; const updateFunction = deleteRow(options.index); return setRows(updateFunction); }); @@ -348,7 +348,6 @@ function useAlterArrayTable({ return (rows) => { if (addTo === "bottom") { - console.log("bottom", newRow(rows.length, false)); rows.push(newRow(rows.length, false)); } else { rows = [newRow(0, false), ...rows];