- fixed issue with saving spreadsheet #6341;
This commit is contained in:
@@ -36,7 +36,7 @@ const parseWorkbook = (val) => {
|
|||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const Spreadsheet = ({ fieldName, defaultValue, setDataFn, template }) => {
|
const Spreadsheet = ({ fieldName, defaultValue, setDataFn, template, register, config = {} }) => {
|
||||||
const containerRef = useRef(null);
|
const containerRef = useRef(null);
|
||||||
const univerRef = useRef(null);
|
const univerRef = useRef(null);
|
||||||
const univerAPIRef = useRef(null);
|
const univerAPIRef = useRef(null);
|
||||||
@@ -102,7 +102,7 @@ const Spreadsheet = ({ fieldName, defaultValue, setDataFn, template }) => {
|
|||||||
saveTimerRef.current = setTimeout(() => {
|
saveTimerRef.current = setTimeout(() => {
|
||||||
const wb = univerAPIRef.current?.getActiveWorkbook();
|
const wb = univerAPIRef.current?.getActiveWorkbook();
|
||||||
if (wb) {
|
if (wb) {
|
||||||
setDataFn(fieldName, wb.save());
|
setDataFn(fieldName, wb.save(), { shouldValidate: true });
|
||||||
}
|
}
|
||||||
}, 300);
|
}, 300);
|
||||||
clearTimeout(restoreTimer);
|
clearTimeout(restoreTimer);
|
||||||
@@ -128,6 +128,10 @@ const Spreadsheet = ({ fieldName, defaultValue, setDataFn, template }) => {
|
|||||||
return () => el.removeEventListener('wheel', handler);
|
return () => el.removeEventListener('wheel', handler);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
register(fieldName, config);
|
||||||
|
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
ref={containerRef}
|
ref={containerRef}
|
||||||
|
|||||||
Reference in New Issue
Block a user