- fixed issue with saving spreadsheet #6341;

This commit is contained in:
Vitalii Kiiko
2026-04-01 16:29:54 +02:00
parent 0e258febe2
commit 69e869cce1

View File

@@ -36,7 +36,7 @@ const parseWorkbook = (val) => {
return null;
};
const Spreadsheet = ({ fieldName, defaultValue, setDataFn, template }) => {
const Spreadsheet = ({ fieldName, defaultValue, setDataFn, template, register, config = {} }) => {
const containerRef = useRef(null);
const univerRef = useRef(null);
const univerAPIRef = useRef(null);
@@ -102,7 +102,7 @@ const Spreadsheet = ({ fieldName, defaultValue, setDataFn, template }) => {
saveTimerRef.current = setTimeout(() => {
const wb = univerAPIRef.current?.getActiveWorkbook();
if (wb) {
setDataFn(fieldName, wb.save());
setDataFn(fieldName, wb.save(), { shouldValidate: true });
}
}, 300);
clearTimeout(restoreTimer);
@@ -128,6 +128,10 @@ const Spreadsheet = ({ fieldName, defaultValue, setDataFn, template }) => {
return () => el.removeEventListener('wheel', handler);
}, []);
useEffect(() => {
register(fieldName, config);
}, []); // eslint-disable-line react-hooks/exhaustive-deps
return (
<div
ref={containerRef}