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)) {
|
||||
// Сохраняем формулу в localStorage
|
||||
saveToStorage(storageKey, curValue);
|
||||
|
||||
// Вычисляем и сохраняем результат
|
||||
try {
|
||||
const formula = extractFormula(curValue);
|
||||
@ -112,6 +111,9 @@ const EditCell = ({ refCell, onChange, disabled, value, tableId, cellId, table }
|
||||
};
|
||||
|
||||
const finishEditing = () => {
|
||||
if (!disabled) {
|
||||
handleSave();
|
||||
}
|
||||
const editingCell = table.getState().editingCell || null;
|
||||
if (editingCell) {
|
||||
contextEndEditing?.(editingCell.row, editingCell.column);
|
||||
@ -132,7 +134,7 @@ const EditCell = ({ refCell, onChange, disabled, value, tableId, cellId, table }
|
||||
return () => {
|
||||
document.removeEventListener('mousedown', handleClickOutside);
|
||||
};
|
||||
}, [ref]);
|
||||
}, [ref, finishEditing]);
|
||||
|
||||
return (
|
||||
<tr>
|
||||
@ -176,16 +178,10 @@ const EditCell = ({ refCell, onChange, disabled, value, tableId, cellId, table }
|
||||
}}
|
||||
onChange={handleChangeValue}
|
||||
value={curValue}
|
||||
onBlur={handleSave}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter' && !e.shiftKey) {
|
||||
e.preventDefault();
|
||||
handleSave();
|
||||
// Закрываем редактирование
|
||||
if (onChange) {
|
||||
// Симулируем завершение редактирования
|
||||
document.activeElement?.blur();
|
||||
}
|
||||
finishEditing();
|
||||
}
|
||||
}}
|
||||
placeholder={isFormulaMode ? 'Введите формулу (начинается с =)' : ''}
|
||||
|
||||
@ -63,7 +63,6 @@ const RealtimeTable = ({ formType, formId, sheetName, direction, year }) => {
|
||||
addRow: contextAddRow,
|
||||
deleteRow: contextDeleteRow,
|
||||
startEditing: contextStartEditing,
|
||||
endEditing: contextEndEditing,
|
||||
} = useRealtime();
|
||||
|
||||
const {
|
||||
@ -181,8 +180,6 @@ const RealtimeTable = ({ formType, formId, sheetName, direction, year }) => {
|
||||
if (cell) {
|
||||
if (editingCell) return;
|
||||
contextStartEditing?.(cell.row, cell.column);
|
||||
} else {
|
||||
contextEndEditing?.(editingCell.row, editingCell.column);
|
||||
}
|
||||
},
|
||||
columnVirtualizerOptions: ({ table }) => ({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user