Compare commits
2 Commits
2cd80343ab
...
bc4e5122c6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc4e5122c6 | ||
|
|
acd4645a4e |
@ -72,7 +72,6 @@ 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);
|
||||||
@ -112,6 +111,9 @@ 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);
|
||||||
@ -132,7 +134,7 @@ const EditCell = ({ refCell, onChange, disabled, value, tableId, cellId, table }
|
|||||||
return () => {
|
return () => {
|
||||||
document.removeEventListener('mousedown', handleClickOutside);
|
document.removeEventListener('mousedown', handleClickOutside);
|
||||||
};
|
};
|
||||||
}, [ref]);
|
}, [ref, finishEditing]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<tr>
|
<tr>
|
||||||
@ -176,16 +178,10 @@ 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();
|
||||||
handleSave();
|
finishEditing();
|
||||||
// Закрываем редактирование
|
|
||||||
if (onChange) {
|
|
||||||
// Симулируем завершение редактирования
|
|
||||||
document.activeElement?.blur();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
placeholder={isFormulaMode ? 'Введите формулу (начинается с =)' : ''}
|
placeholder={isFormulaMode ? 'Введите формулу (начинается с =)' : ''}
|
||||||
|
|||||||
@ -63,7 +63,6 @@ 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 {
|
||||||
@ -181,8 +180,6 @@ 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 }) => ({
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user