Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions packages/core/ui/core/view-base/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1011,8 +1011,17 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
// }
}

/**
* if _setupAsRootView is called it means it is not supposed to be
* added to a parent. However parent can be set before for the purpose
* of CSS variables/classes. That variable ensures that _addViewToNativeVisualTree
* is not called in _setupAsRootView
*/
mIsRootView = false;
_setupAsRootView(context: any): void {
this.mIsRootView = true;
this._setupUI(context);
this.mIsRootView = false;
}

/**
Expand All @@ -1025,7 +1034,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
// this check is unnecessary as this function should never be called when this._context === context as it means the view was somehow detached,
// which is only possible by setting reusable = true. Adding it either way for feature flag safety
if (this.reusable) {
if (this.parent && !this._isAddedToNativeVisualTree) {
if (!this.mIsRootView && this.parent && !this._isAddedToNativeVisualTree) {
const nativeIndex = this.parent._childIndexToNativeChildIndex(atIndex);
this._isAddedToNativeVisualTree = this.parent._addViewToNativeVisualTree(this, nativeIndex);
}
Expand Down Expand Up @@ -1100,7 +1109,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition

this.setNativeView(nativeView);

if (this.parent) {
if (!this.mIsRootView && this.parent) {
const nativeIndex = this.parent._childIndexToNativeChildIndex(atIndex);
this._isAddedToNativeVisualTree = this.parent._addViewToNativeVisualTree(this, nativeIndex);
}
Expand Down