Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically loaded (predefined) Layout with strange popout behaviour #28

Open
JonasC97 opened this issue Mar 6, 2023 · 0 comments
Open

Comments

@JonasC97
Copy link

JonasC97 commented Mar 6, 2023

Hi, I discovered a strange GoldenLayout behaviour regarding popouts.

When I set up the project and started it without changes, I can click together a layout with the controls and the popouts work as they should. Same goes for the predefined layouts that you can switch between in the controls.

But when I adapted the AppComponent, so that one of the predefined layouts are loaded automatically during the ngAfterViewInit() in app.component.ts, the popout does not pop out the component only, but the whole application like in the picture below:

popoutBug

Here is the code from the app.component.ts:

import { AfterViewInit, Component, ViewChild } from '@angular/core';
import { LayoutConfig, ComponentItemConfig } from 'golden-layout';
import { ColorComponent } from './color.component';
import { ControlsComponent } from './controls.component';
import { GoldenLayoutHostComponent } from './golden-layout-host.component';
import { predefinedLayouts } from "./predefined-layouts"

@Component({
  selector: 'app-root',
  template: `
      <button (click)="test()">Test</button>
      <app-controls #controls></app-controls>
      <app-golden-layout-host #goldenLayoutHost></app-golden-layout-host>   
  `,
  styles: [
    `
      :host {
        height: 100%;
        width: 100%;
        display: flex;
        flex-direction: row;
      }
    `
  ]
})
export class AppComponent implements AfterViewInit {
  title = 'golden-layout-ng-app';

  private _controlsElement: HTMLElement;

  responsiveConfig: LayoutConfig = predefinedLayouts[2].config

  @ViewChild('controls') private _controlsComponent: ControlsComponent; 
  @ViewChild('goldenLayoutHost') private _goldenLayoutHostComponent: GoldenLayoutHostComponent; 

  ngAfterViewInit() {
    setTimeout(() => {
      this._controlsElement = this._controlsComponent.element;

      this._goldenLayoutHostComponent.initialise();
      this._controlsComponent.initialise(this._goldenLayoutHostComponent);
  
      if (this._goldenLayoutHostComponent.isGoldenLayoutSubWindow) {
        this._controlsElement.style.display = 'none';
      }

      this._goldenLayoutHostComponent.goldenLayout.loadLayout(this.responsiveConfig);

    }, 0);
  }

  test(){
    // this._goldenLayoutHostComponent.goldenLayout.loadLayout(this.responsiveConfig);
  }
}

Do you know, why this is happening and how I can avoid this and still load a layout in the initialization process?

Thanks in regard!
Jonas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant