Compare commits

..

No commits in common. "bc4e5122c68b55e940be97d746fc2228cbfe957c" and "2cd80343ab85d97a0e441566a2e37e0e9f598c78" have entirely different histories.

2 changed files with 12 additions and 5 deletions

View File

@ -72,6 +72,7 @@ const EditCell = ({ refCell, onChange, disabled, value, tableId, cellId, table }
if (isFormula(curValue)) { if (isFormula(curValue)) {
// Сохраняем формулу в localStorage // Сохраняем формулу в localStorage
saveToStorage(storageKey, curValue); saveToStorage(storageKey, curValue);
// Вычисляем и сохраняем результат // Вычисляем и сохраняем результат
try { try {
const formula = extractFormula(curValue); const formula = extractFormula(curValue);
@ -111,9 +112,6 @@ const EditCell = ({ refCell, onChange, disabled, value, tableId, cellId, table }
}; };
const finishEditing = () => { const finishEditing = () => {
if (!disabled) {
handleSave();
}
const editingCell = table.getState().editingCell || null; const editingCell = table.getState().editingCell || null;
if (editingCell) { if (editingCell) {
contextEndEditing?.(editingCell.row, editingCell.column); contextEndEditing?.(editingCell.row, editingCell.column);
@ -134,7 +132,7 @@ const EditCell = ({ refCell, onChange, disabled, value, tableId, cellId, table }
return () => { return () => {
document.removeEventListener('mousedown', handleClickOutside); document.removeEventListener('mousedown', handleClickOutside);
}; };
}, [ref, finishEditing]); }, [ref]);
return ( return (
<tr> <tr>
@ -178,10 +176,16 @@ const EditCell = ({ refCell, onChange, disabled, value, tableId, cellId, table }
}} }}
onChange={handleChangeValue} onChange={handleChangeValue}
value={curValue} value={curValue}
onBlur={handleSave}
onKeyDown={(e) => { onKeyDown={(e) => {
if (e.key === 'Enter' && !e.shiftKey) { if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault(); e.preventDefault();
finishEditing(); handleSave();
// Закрываем редактирование
if (onChange) {
// Симулируем завершение редактирования
document.activeElement?.blur();
}
} }
}} }}
placeholder={isFormulaMode ? 'Введите формулу (начинается с =)' : ''} placeholder={isFormulaMode ? 'Введите формулу (начинается с =)' : ''}

View File

@ -63,6 +63,7 @@ const RealtimeTable = ({ formType, formId, sheetName, direction, year }) => {
addRow: contextAddRow, addRow: contextAddRow,
deleteRow: contextDeleteRow, deleteRow: contextDeleteRow,
startEditing: contextStartEditing, startEditing: contextStartEditing,
endEditing: contextEndEditing,
} = useRealtime(); } = useRealtime();
const { const {
@ -180,6 +181,8 @@ const RealtimeTable = ({ formType, formId, sheetName, direction, year }) => {
if (cell) { if (cell) {
if (editingCell) return; if (editingCell) return;
contextStartEditing?.(cell.row, cell.column); contextStartEditing?.(cell.row, cell.column);
} else {
contextEndEditing?.(editingCell.row, editingCell.column);
} }
}, },
columnVirtualizerOptions: ({ table }) => ({ columnVirtualizerOptions: ({ table }) => ({