Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions tns-core-modules/ui/layouts/grid-layout/grid-layout-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export * from "../layout-base";

function validateArgs(element: View): View {
if (!element) {
throw new Error("element cannot be null or undefinied.");
throw new Error("element cannot be null or undefined.");
}
return element;
}
Expand Down Expand Up @@ -291,7 +291,7 @@ export class GridLayoutBase extends LayoutBase implements GridLayoutDefinition {
}

protected invalidate(): void {
// handled natively in android and overriden in ios.
// handled natively in android and overridden in ios.
}

set rows(value: string) {
Expand Down
4 changes: 4 additions & 0 deletions tns-core-modules/ui/layouts/grid-layout/grid-layout.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ export class GridLayout extends GridLayoutBase {

this.eachLayoutChild((child, last) => {
let measureSpecs = this.map.get(child);
if (!measureSpecs) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was reviewing our code and I am not sure trying to fix this exceptional situation by registering layout child here is a good idea. How about just skipping this specific layout child instead (as obviously something is not right with its current state)?

if (!measureSpecs) { 
    continue;
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've finally managed to reproduce the problem see: #7226 (comment)

I'm not sure what the best solution is or if we just use components+layouts incorrectly.

Just skipping as you suggest results in the component not being rendered.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @m-abs thank you isolating the problem!
So just skipping the iteration when measureSpec is undefined is not an option, ok. Will investigate the code on the nativescript-angular side a bit but if I don't find a better solution I am going to merge yours as is.

Meanwhile, there is also a workaround that you can use -- wrap the contents of your sub1 component (sub1.component.html) in any kind of layout like this:

<GridLayout>
    <ns-sub2></ns-sub2>
</GridLayout>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@m-abs I think we found the root of the problem in the ProxyViewContainer class -- see my commit here: 3acfc70

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

return;
}

this.updateMeasureSpecs(child, measureSpecs);
this.helper.addMeasureSpec(measureSpecs);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ export class ProxyViewContainer extends LayoutBase implements ProxyViewContainer
const oldLayout = <LayoutBase>oldParent;

if (addingToParent && newLayout instanceof LayoutBase) {
this.eachChildView((child) => {
this.eachLayoutChild((child) => {
newLayout._registerLayoutChild(child);
return true;
});
} else if (oldLayout instanceof LayoutBase) {
this.eachChildView((child) => {
this.eachLayoutChild((child) => {
oldLayout._unregisterLayoutChild(child);
return true;
});
Expand Down