Skip to content

Commit 4c032d0

Browse files
zyy7259LeoYuan
authored andcommitted
feat: refine nesting drawer
1 parent 9d187cc commit 4c032d0

File tree

1 file changed

+18
-9
lines changed
  • packages/editor-skeleton/src/components/popup

1 file changed

+18
-9
lines changed

packages/editor-skeleton/src/components/popup/index.tsx

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ export class PopupPipe {
1111

1212
private currentId?: string;
1313

14-
create(props?: object): { send: (content: ReactNode, title: ReactNode) => void; show: (target: Element) => void } {
14+
create(props?: object): {
15+
send: (content: ReactNode, title: ReactNode) => void;
16+
show: (target: Element) => void;
17+
} {
1518
let sendContent: ReactNode = null;
1619
let sendTitle: ReactNode = null;
1720
const id = uniqueId('popup');
@@ -60,26 +63,30 @@ export class PopupPipe {
6063
}
6164
}
6265

63-
export default class PopupService extends Component<{ popupPipe?: PopupPipe; actionKey?: string; safeId?: string }> {
66+
export default class PopupService extends Component<{
67+
popupPipe?: PopupPipe;
68+
actionKey?: string;
69+
safeId?: string;
70+
popupContainer?: string;
71+
}> {
6472
private popupPipe = this.props.popupPipe || new PopupPipe();
6573

6674
componentWillUnmount() {
6775
this.popupPipe.purge();
6876
}
6977

70-
7178
render() {
72-
const { children, actionKey, safeId } = this.props;
79+
const { children, actionKey, safeId, popupContainer } = this.props;
7380
return (
7481
<PopupContext.Provider value={this.popupPipe}>
7582
{children}
76-
<PopupContent key={`pop${ actionKey}`} safeId={safeId} />
83+
<PopupContent key={`pop${actionKey}`} safeId={safeId} popupContainer={popupContainer} />
7784
</PopupContext.Provider>
7885
);
7986
}
8087
}
8188

82-
export class PopupContent extends PureComponent<{ safeId?: string }> {
89+
export class PopupContent extends PureComponent<{ safeId?: string; popupContainer?: string }> {
8390
static contextType = PopupContext;
8491

8592
popupContainerId = uniqueId('popupContainer');
@@ -143,11 +150,11 @@ export class PopupContent extends PureComponent<{ safeId?: string }> {
143150
visible={visible}
144151
offset={[offsetX, 0]}
145152
hasMask={false}
146-
onVisibleChange={(visible, type) => {
153+
onVisibleChange={(_visible, type) => {
147154
if (avoidLaterHidden) {
148155
return;
149156
}
150-
if (!visible && type === 'closeClick') {
157+
if (!_visible && type === 'closeClick') {
151158
this.setState({ visible: false });
152159
}
153160
}}
@@ -159,17 +166,19 @@ export class PopupContent extends PureComponent<{ safeId?: string }> {
159166
id={this.props.safeId}
160167
safeNode={id}
161168
closeable
169+
container={this.props.popupContainer}
162170
>
163171
<div className="lc-ballon-title">{title}</div>
164172
<div className="lc-ballon-content">
165-
<PopupService actionKey={actionKey} safeId={id}>
173+
<PopupService actionKey={actionKey} safeId={id} popupContainer={this.popupContainerId}>
166174
<ConfigProvider popupContainer={this.popupContainerId}>
167175
{content}
168176
</ConfigProvider>
169177
</PopupService>
170178
</div>
171179
<div id={this.popupContainerId} />
172180
<div id="engine-variable-setter-dialog" />
181+
<div id="engine-popup-container" />
173182
</Drawer>
174183
);
175184
}

0 commit comments

Comments
 (0)