Skip to content

Commit 4c1f6e9

Browse files
authored
Merge pull request #4743 from easyops-cn/steve/v3-control-node-bug
Steve/v3-control-node-bug
2 parents ecea0b3 + c2d3e93 commit 4c1f6e9

File tree

14 files changed

+489
-321
lines changed

14 files changed

+489
-321
lines changed

cypress/e2e/control-nodes.spec.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,5 +263,29 @@ for (const port of Cypress.env("ports")) {
263263

264264
cy.get("@console.error").should("not.be.called");
265265
});
266+
267+
it("should handle nested :if rerender", () => {
268+
cy.visit(`${origin}/e2e/nested-if`, {
269+
onBeforeLoad(win) {
270+
cy.spy(win.console, "error").as("console.error");
271+
},
272+
});
273+
274+
cy.expectMainContents([
275+
"Click 1Click 2Second button is not clicked",
276+
"This should always be shown",
277+
]);
278+
279+
cy.contains("Click 1").click();
280+
cy.expectMainContents([
281+
"Click 1Click 2Second button is not clicked",
282+
"This should always be shown",
283+
]);
284+
285+
cy.contains("Click 2").click();
286+
cy.expectMainContents(["Click 1Click 2", "This should always be shown"]);
287+
288+
cy.get("@console.error").should("not.be.called");
289+
});
266290
});
267291
}

mock-micro-apps/e2e/storyboard.yaml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,3 +1040,90 @@ routes:
10401040
# - path: '${APP.homepage}/initial-rerender/apps/:group?'
10411041
# exact: true
10421042
# bricks: []
1043+
1044+
- path: '${APP.homepage}/nested-if'
1045+
context:
1046+
- name: value
1047+
value: null
1048+
- name: alwaysFalsy
1049+
value: <% !!CTX.value %>
1050+
track: true
1051+
- name: secondButtonClicked
1052+
value: false
1053+
bricks:
1054+
- brick: div
1055+
iid: 1
1056+
children:
1057+
- brick: p
1058+
iid: 2
1059+
children:
1060+
- brick: button
1061+
iid: 3
1062+
properties:
1063+
textContent: Click 1
1064+
events:
1065+
click:
1066+
- action: context.replace
1067+
args:
1068+
- value
1069+
- false
1070+
- brick: button
1071+
iid: 4
1072+
properties:
1073+
textContent: Click 2
1074+
events:
1075+
click:
1076+
- action: context.replace
1077+
args:
1078+
- secondButtonClicked
1079+
- true
1080+
- brick: :if
1081+
iid: 5
1082+
dataSource: <%= !CTX.secondButtonClicked %>
1083+
children:
1084+
- brick: p
1085+
iid: 6
1086+
properties:
1087+
textContent: Second button is not clicked
1088+
- brick: :if
1089+
iid: 7
1090+
dataSource: <%= CTX.alwaysFalsy %>
1091+
children:
1092+
- brick: p
1093+
iid: 8
1094+
properties:
1095+
textContent: This should never be shown
1096+
- brick: p
1097+
iid: 9
1098+
properties:
1099+
textContent: This should always be shown
1100+
1101+
- path: '${APP.homepage}/debug'
1102+
context:
1103+
- name: debug
1104+
value: false
1105+
bricks:
1106+
- brick: button
1107+
properties:
1108+
textContent: Toggle Debug
1109+
events:
1110+
click:
1111+
- action: context.replace
1112+
args:
1113+
- debug
1114+
- <% !CTX.debug %>
1115+
- brick: e2e.list-by-use-brick
1116+
properties:
1117+
data: [1, 2]
1118+
useBrick:
1119+
- brick: div
1120+
children:
1121+
- brick: div
1122+
portal: true
1123+
children:
1124+
- brick: :if
1125+
dataSource: <%= CTX.debug %>
1126+
children:
1127+
- brick: p
1128+
properties:
1129+
textContent: '<% `Debug: ${DATA}` %>'

packages/brick-container/scripts/start.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const server = new WebpackDevServer(
2828
hot: true,
2929
client: {
3030
overlay: false,
31+
logging: "warn",
3132
},
3233
devMiddleware: {
3334
publicPath: baseHref,

packages/react-runtime/src/ReactUseBrick.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,10 @@ let ReactUseBrick = function ReactUseBrick({
7676
(element: HTMLElement | null) => {
7777
if (element) {
7878
mountResult.current = __secret_internals.mountUseBrick(
79-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
8079
renderResult!,
8180
element
8281
);
8382
} else {
84-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
8583
__secret_internals.unmountUseBrick(renderResult!, mountResult.current!);
8684
mountResult.current = undefined;
8785
}
@@ -102,7 +100,7 @@ let ReactUseBrick = function ReactUseBrick({
102100
return null;
103101
}
104102

105-
const WebComponent = tagName as any;
103+
const WebComponent = tagName as "div";
106104
return <WebComponent key={renderKey} ref={_refCallback} />;
107105
};
108106

0 commit comments

Comments
 (0)