Skip to content

Commit 504f501

Browse files
edloidasalansemenov
authored andcommitted
Enonic UI: Incorrect rendering in LegacyElement children #4126
1 parent 637e7ef commit 504f501

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

src/main/resources/assets/admin/common/js/ui2/ActionButton.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,17 @@ export class ActionButton<T extends Action = Action> extends LegacyElement<typeo
5555
this.updateProps();
5656
}
5757

58-
doRender(): Q.Promise<boolean> {
58+
setEnabled(enabled: boolean): void {
59+
this.actionProps.action.setEnabled(enabled);
60+
}
61+
62+
protected renderJsx(): void {
5963
const actionButton = createElement(this.component, this.props.get());
6064
const tooltip = createElement(UI.Tooltip, {
6165
value: unwrap(this.props.get().title),
6266
children: actionButton,
6367
} satisfies UI.TooltipProps);
6468
render(tooltip, this.getHTMLElement());
65-
return super.doRender();
66-
}
67-
68-
setEnabled(enabled: boolean): void {
69-
this.actionProps.action.setEnabled(enabled);
7069
}
7170
}
7271

src/main/resources/assets/admin/common/js/ui2/ActionIcon.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,17 @@ export class ActionIcon extends LegacyElement<typeof UI.IconButton> {
5252
this.updateProps();
5353
}
5454

55-
doRender(): Q.Promise<boolean> {
56-
const ActionIcon = h(this.component, this.props.get());
55+
setEnabled(enabled: boolean): void {
56+
this.actionProps.action.setEnabled(enabled);
57+
}
58+
59+
protected renderJsx(): void {
60+
const actionIcon = h(this.component, this.props.get());
5761
const tooltip = h(UI.Tooltip, {
5862
value: unwrap(this.props.get().title),
59-
children: ActionIcon,
63+
children: actionIcon,
6064
} satisfies UI.TooltipProps);
6165
render(tooltip, this.getHTMLElement());
62-
return super.doRender();
63-
}
64-
65-
setEnabled(enabled: boolean): void {
66-
this.actionProps.action.setEnabled(enabled);
6766
}
6867
}
6968

src/main/resources/assets/admin/common/js/ui2/LegacyElement.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ export class LegacyElement<C extends ComponentType<object>, P extends ComponentP
2626
this.props.set({...this.props.get(), ...props});
2727
}
2828

29-
doRender(): Q.Promise<boolean> {
29+
protected renderJsx(): void {
3030
render(createElement(this.component, this.props.get()), this.getHTMLElement());
31+
}
32+
33+
doRender(): Q.Promise<boolean> {
34+
this.renderJsx();
3135
return super.doRender();
3236
}
3337

0 commit comments

Comments
 (0)