@saltcorn/workflow-editor 1.7.0-beta.2 → 1.7.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/workflow_bundle.js +1 -1
- package/package.json +1 -1
- package/src/WorkflowEditor.jsx +23 -3
package/package.json
CHANGED
package/src/WorkflowEditor.jsx
CHANGED
|
@@ -831,7 +831,7 @@ const WorkflowEditor = ({ data }) => {
|
|
|
831
831
|
const [loading, setLoading] = useState(false);
|
|
832
832
|
const [message, setMessage] = useState("");
|
|
833
833
|
const [error, setError] = useState("");
|
|
834
|
-
const [modal,
|
|
834
|
+
const [modal, setModalState] = useState(null);
|
|
835
835
|
const [savingModal, setSavingModal] = useState(false);
|
|
836
836
|
const [savingPositions, setSavingPositions] = useState(false);
|
|
837
837
|
const [sizeSyncing, setSizeSyncing] = useState(false);
|
|
@@ -842,6 +842,13 @@ const WorkflowEditor = ({ data }) => {
|
|
|
842
842
|
return 600;
|
|
843
843
|
});
|
|
844
844
|
const modalRef = useRef(null);
|
|
845
|
+
// dispose Monaco editors in the drawer before React swaps/removes its HTML
|
|
846
|
+
const setModal = useCallback((next) => {
|
|
847
|
+
if (modalRef.current && window.dispose_monaco_in)
|
|
848
|
+
window.dispose_monaco_in(modalRef.current);
|
|
849
|
+
setModalState(next);
|
|
850
|
+
}, []);
|
|
851
|
+
const stepFormRequestRef = useRef(null);
|
|
845
852
|
const drawerRef = useRef(null);
|
|
846
853
|
const shellRef = useRef(null);
|
|
847
854
|
const resizingRef = useRef(false);
|
|
@@ -1457,6 +1464,9 @@ const WorkflowEditor = ({ data }) => {
|
|
|
1457
1464
|
|
|
1458
1465
|
const openStepForm = useCallback(
|
|
1459
1466
|
async ({ stepId, initial_step, after_step } = {}) => {
|
|
1467
|
+
stepFormRequestRef.current?.abort();
|
|
1468
|
+
const controller = new AbortController();
|
|
1469
|
+
stepFormRequestRef.current = controller;
|
|
1460
1470
|
try {
|
|
1461
1471
|
setError("");
|
|
1462
1472
|
const descriptor = {
|
|
@@ -1471,14 +1481,24 @@ const WorkflowEditor = ({ data }) => {
|
|
|
1471
1481
|
url.searchParams.set("vw", window.innerWidth);
|
|
1472
1482
|
if (initial_step) url.searchParams.set("initial_step", "true");
|
|
1473
1483
|
if (after_step) url.searchParams.set("after_step", after_step);
|
|
1474
|
-
const res = await fetchJson(url.toString()
|
|
1484
|
+
const res = await fetchJson(url.toString(), {
|
|
1485
|
+
signal: controller.signal,
|
|
1486
|
+
});
|
|
1487
|
+
if (stepFormRequestRef.current !== controller) return;
|
|
1475
1488
|
setModal({ title: res.title, body: res.form, stepId: stepId || null });
|
|
1476
1489
|
} catch (e) {
|
|
1490
|
+
if (e.name === "AbortError") return;
|
|
1477
1491
|
clearDrawerState();
|
|
1478
1492
|
setError(e.message);
|
|
1479
1493
|
}
|
|
1480
1494
|
},
|
|
1481
|
-
[
|
|
1495
|
+
[
|
|
1496
|
+
clearDrawerState,
|
|
1497
|
+
data.urls.stepForm,
|
|
1498
|
+
fetchJson,
|
|
1499
|
+
persistDrawerState,
|
|
1500
|
+
setModal,
|
|
1501
|
+
]
|
|
1482
1502
|
);
|
|
1483
1503
|
|
|
1484
1504
|
const submitStepForm = useCallback(
|