Skip to content

Commit b925940

Browse files
committed
Cause tour component to not fail on initial load
turns out it just required ?!
1 parent 9d1d733 commit b925940

File tree

2 files changed

+28
-26
lines changed

2 files changed

+28
-26
lines changed
Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { styleControl } from "comps/controls/styleControl";
2-
import { SelectStyle } from "comps/controls/styleControlConstants";
31
import { trans } from "i18n";
42
import {
5-
CommonNameConfig, MultiBaseComp,
3+
CommonNameConfig,
4+
MultiBaseComp,
65
NameConfig,
76
stringExposingStateControl,
87
UICompBuilder,
@@ -13,54 +12,57 @@ import { baseSelectRefMethods, TourChildrenMap, TourPropertyView } from "./tourC
1312
import { TourInputCommonConfig } from "./tourInputConstants";
1413
import { Tour, TourProps } from "antd";
1514
import { PlacementType } from "@lowcoder-ee/comps/controls/tourStepControl";
16-
import { useContext } from "react";
15+
import React, { Suspense, useContext } from "react";
1716
import { EditorContext } from "@lowcoder-ee/comps/editorState";
1817
import { GridItemComp } from "@lowcoder-ee/comps/comps/gridItemComp";
1918
import { HookComp } from "@lowcoder-ee/comps/hooks/hookComp";
2019
import { TemporaryStateItemComp } from "@lowcoder-ee/comps/comps/temporaryStateComp";
21-
import { delay } from "redux-saga/effects";
2220

2321
/**
2422
* This component builds the Property Panel and the fake 'UI' for the Tour component
2523
*/
26-
let TourBasicComp = (function () {
24+
let TourBasicComp = (function() {
2725
const childrenMap = {
2826
...TourChildrenMap,
2927
defaultValue: stringExposingStateControl("defaultValue"),
30-
value: stringExposingStateControl("value"),
28+
value: stringExposingStateControl("value")
3129
// style: styleControl(SelectStyle),
3230
};
3331
return new UICompBuilder(childrenMap, (props, dispatch) => {
3432
const editorState = useContext(EditorContext);
3533
const compMap: (GridItemComp | HookComp | InstanceType<typeof TemporaryStateItemComp>)[] = Object.values(editorState.getAllUICompMap());
36-
37-
const steps: TourProps['steps'] = props.options.map((step) => {
34+
35+
const steps: TourProps["steps"] = props.options.map((step) => {
3836
const targetName = step.target;
3937
let target = undefined;
4038
const compListItem = compMap.find((compItem) => compItem.children.name.getView() === targetName);
4139
if (compListItem) {
42-
console.log(`setting selected comp to ${compListItem}`)
40+
console.log(`setting selected comp to ${compListItem}`);
4341
try {
44-
target = ((compListItem as MultiBaseComp).children.comp as GridItemComp).getRef();
42+
target = ((compListItem as MultiBaseComp).children.comp as GridItemComp).getRef?.();
4543
} catch (e) {
46-
target = ((compListItem as MultiBaseComp).children.comp as HookComp).getRef();
44+
target = ((compListItem as MultiBaseComp).children.comp as HookComp).getRef?.();
4745
}
4846
}
49-
47+
5048
return {
5149
title: step.title,
5250
description: step.description,
5351
target: target?.current,
5452
arrow: step.arrow || true,
55-
placement: step.placement as PlacementType,
56-
}
57-
})
53+
placement: step.placement as PlacementType
54+
};
55+
});
5856

59-
return (<Tour
60-
steps={steps}
61-
open={props.open.value}
62-
onClose={() => props.open.onChange(false)}
63-
/>)
57+
return (
58+
<Suspense fallback={<div>loading</div>}>
59+
<Tour
60+
steps={steps}
61+
open={props.open.value}
62+
onClose={() => props.open.onChange(false)}
63+
/>
64+
</Suspense>
65+
);
6466
})
6567
.setPropertyViewFn((children) => <TourPropertyView {...children} />)
6668
.setExposeMethodConfigs(baseSelectRefMethods)
@@ -72,17 +74,17 @@ TourBasicComp = withMethodExposing(TourBasicComp, [
7274
method: {
7375
name: "startTour",
7476
description: "Triggers the tour to start",
75-
params: [],
77+
params: []
7678
},
7779
execute: (comp, values) => {
78-
comp.children.open.getView().onChange(true)
80+
comp.children.open.getView().onChange(true);
7981
}
8082
}
81-
])
83+
]);
8284

8385
export const TourComp = withExposingConfigs(TourBasicComp, [
8486
new NameConfig("value", trans("selectInput.valueDesc")),
8587
new NameConfig("inputValue", trans("select.inputValueDesc")),
8688
...TourInputCommonConfig,
87-
...CommonNameConfig,
89+
...CommonNameConfig
8890
]);

client/packages/lowcoder/src/comps/controls/tourStepControl.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ TourStep = class extends TourStep implements TourStepCompProperty {
419419
placeholder: "Welcome to lowcoder, this is your first tutorial step",
420420
})}
421421
{this.children.target.propertyView({
422-
label: "TARGET",
422+
label: "Component",
423423
radioButton: false,
424424
})}
425425
{this.children.placement.propertyView({

0 commit comments

Comments
 (0)