Skip to content

Commit a9e81f1

Browse files
Add allowRenderToDetachedTable flag (#784)
* Revert "Support npm >= 7 (#658)" This reverts commit 5d35a0e. * Add allowRenderToDetachedTable flag * Update version * Small fix
1 parent 7bc8e5d commit a9e81f1

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

packages/devextreme-react-generator/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/devextreme-react-generator/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"author": "Developer Express Inc.",
33
"name": "devextreme-react-generator",
4-
"version": "1.3.2",
4+
"version": "1.3.3",
55
"description": "DevExtreme React UI and Visualization Components",
66
"repository": {
77
"type": "git",

packages/devextreme-react-generator/src/component-generator.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ const USE_REQUEST_ANIMATION_FRAME: Set<string> = new Set([
9898
'dxDataGrid',
9999
]);
100100

101+
const USE_DETACHED_TABLE: Set<string> = new Set([
102+
'dxDataGrid',
103+
'dxTreeList',
104+
]);
105+
101106
function getIndent(indent: number) {
102107
return Array(indent * 2 + 1).join(' ');
103108
}
@@ -353,6 +358,7 @@ const renderComponent: (model: {
353358
renderedPropTypings?: string[];
354359
isPortalComponent?: boolean;
355360
useRequestAnimationFrameFlag?: boolean;
361+
allowRenderToDetachedTable?: boolean;
356362
typeParams: string[] | undefined;
357363
}) => string = createTempate(
358364
`class <#= it.className #>${TYPE_PARAMS_WITH_DEFAULTS} extends BaseComponent<React.PropsWithChildren<<#= it.optionsName #>${TYPE_PARAMS}>> {
@@ -367,6 +373,10 @@ const renderComponent: (model: {
367373
L1}protected useRequestAnimationFrameFlag = true;\n`
368374
+ '<#?#>'
369375

376+
+ `<#? it.allowRenderToDetachedTable #>${
377+
L1}protected allowRenderToDetachedTable = true;\n`
378+
+ '<#?#>'
379+
370380
+ `<#? it.isPortalComponent #>${
371381
L1}protected isPortalComponent = true;\n`
372382
+ '<#?#>'
@@ -600,6 +610,7 @@ function generate(component: IComponent): string {
600610
renderedPropTypings,
601611
expectedChildren: component.expectedChildren,
602612
useRequestAnimationFrameFlag: USE_REQUEST_ANIMATION_FRAME.has(widgetName),
613+
allowRenderToDetachedTable: USE_DETACHED_TABLE.has(widgetName),
603614
isPortalComponent: PORTAL_COMPONENTS.has(widgetName),
604615
typeParams: component.optionsTypeParams?.length ? component.optionsTypeParams : undefined,
605616
}),

packages/devextreme-react/src/core/component-base.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ abstract class ComponentBase<P extends IHtmlOptions> extends React.PureComponent
6767

6868
protected useRequestAnimationFrameFlag = false;
6969

70+
protected allowRenderToDetachedTable = false;
71+
7072
protected useDeferUpdateForTemplates = false;
7173

7274
constructor(props: P) {
@@ -116,11 +118,18 @@ abstract class ComponentBase<P extends IHtmlOptions> extends React.PureComponent
116118
element = element || this._element;
117119

118120
const config = this._getConfig();
121+
const initialOptions = this._optionsManager.getInitialOptions(config);
122+
const hasDetachedFlag = Object.keys(initialOptions).includes('allowRenderToDetachedTable');
123+
124+
if (!hasDetachedFlag && this.allowRenderToDetachedTable) {
125+
initialOptions.allowRenderToDetachedTable = true;
126+
}
127+
119128
this._instance = new this._WidgetClass(
120129
element,
121130
{
122131
templatesRenderAsynchronously: true,
123-
...this._optionsManager.getInitialOptions(config),
132+
...initialOptions,
124133
},
125134
);
126135

0 commit comments

Comments
 (0)