@jetbrains/ring-ui 7.0.14 → 7.0.15

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.
@@ -9,7 +9,8 @@ import dataTests from '../global/data-tests';
9
9
  import Shortcuts from '../shortcuts/shortcuts';
10
10
  import TabTrap from '../tab-trap/tab-trap';
11
11
  import Button from '../button/button';
12
- import { PopupTarget } from '../popup/popup.target';
12
+ import { PopupTarget, PopupTargetContext } from '../popup/popup.target';
13
+ import { getPopupContainer } from '../popup/popup';
13
14
  import { preventerFactory as scrollPreventerFactory } from './dialog__body-scroll-preventer';
14
15
  import styles from './dialog.css';
15
16
  /**
@@ -123,7 +124,18 @@ export default class Dialog extends PureComponent {
123
124
  if (native) {
124
125
  return (_jsx("dialog", { className: classNames(styles.nativeDialog, className), ref: this.nativeDialog, children: _jsx(PopupTarget, { id: this.uid, className: styles.popupTarget, children: target => (_jsxs(_Fragment, { children: [content, target] })) }) }));
125
126
  }
126
- return (show &&
127
- createPortal(_jsx(PopupTarget, { id: this.uid, className: styles.popupTarget, children: target => (_jsxs(TabTrap, { trapDisabled: !trapFocus, "data-test": dataTests('ring-dialog-container', dataTest), ref: this.dialogRef, className: classes, role: "presentation", ...restProps, children: [content, target] })) }), portalTarget instanceof HTMLElement ? portalTarget : document.body));
127
+ return (show && (_jsx(PopupTargetContext.Consumer, { children: contextTarget => {
128
+ let targetElement = document.body;
129
+ if (portalTarget instanceof HTMLElement) {
130
+ targetElement = portalTarget;
131
+ }
132
+ else if (contextTarget != null) {
133
+ const container = getPopupContainer(contextTarget);
134
+ if (container != null) {
135
+ targetElement = container;
136
+ }
137
+ }
138
+ return createPortal(_jsx(PopupTarget, { id: this.uid, className: styles.popupTarget, children: target => (_jsxs(TabTrap, { trapDisabled: !trapFocus, "data-test": dataTests('ring-dialog-container', dataTest), ref: this.dialogRef, className: classes, role: "presentation", ...restProps, children: [content, target] })) }), targetElement);
139
+ } })));
128
140
  }
129
141
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetbrains/ring-ui",
3
- "version": "7.0.14",
3
+ "version": "7.0.15",
4
4
  "description": "JetBrains UI library",
5
5
  "author": "JetBrains",
6
6
  "license": "Apache-2.0",