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

igx-grid not resizing properly when closing igx-nav-drawer #3639

Closed
joedementri opened this issue Jan 16, 2019 · 6 comments
Closed

igx-grid not resizing properly when closing igx-nav-drawer #3639

joedementri opened this issue Jan 16, 2019 · 6 comments

Comments

@joedementri
Copy link

Description

When closing a navdrawer, the Igx Grid does not resize, as it stays the same width as if the navdrawer wasn't closed.

  • igniteui-angular version: 6.2.3
  • browser: Chrome

Steps to reproduce

  1. Go to a page without a grid. Open the navdrawer.
  2. Use the navdrawer to navigate to a page with a grid.
  3. Close the navdrawer.

Result

When the navdrawer remains is open, the page with the grid loads in
When the navdrawer is closed, the grid doesn't resize, staying the same width as it did before the navdrawer was closed.

Expected result

Expect the Igx Grid to resize to the full width of page after a navdrawer is closed.

Attachments

  1. Start at a screen without the IgxGrid, open the navdrawer

1 - screen without grid

  1. Navigate to the page with a grid from the navdrawer

2 - table with navdrawer open

  1. Close the navdrawer

3 - grid with navdrawer closed

@mpavlinov
Copy link
Contributor

The problem is in the grid width calculation. I'll take it.

@mpavlinov
Copy link
Contributor

Linking a forum post that it looks like has the same issue: https://www.infragistics.com/community/forums/f/ignite-ui-for-angular/119473/simplest-way-to-style-grid

@joedementri
Copy link
Author

@mpavlinov

We found a temporary solution. We created an observable on the the navdrawer closing, and had each component with tables subscribe to that observable in the ngOnInit method and reflowing.

Service w/ Observable

import { Injectable } from '@angular/core';
import { Subject } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class ScreenResizeEventService {

  private _resizeEvents = new Subject<string>();
  resizeEvents$ = this._resizeEvents.asObservable();

  constructor() { }

  public next(resizeEvent: string) {
    this._resizeEvents.next(resizeEvent);
  }
}

Component with Navdrawer

public ngOnInit(): void {
    this.navdrawer.closed.subscribe(closed => {
      this.sres.next('closed');
    });
    // Other code
}

Component with Table

ngOnInit(): void {
    // Other code
    this.sres.resizeEvents$.subscribe(resized => {
      this.grid.reflow();
    });
}

@mpavlinov
Copy link
Contributor

@joedementri Yes. The current solution is to call manually IgxGridComponent.reflow when the IgxNavigationDrawerComponent opens/closes. The limitation is because the horizontal virtualization relies on pixels and we're recalculating percents to pixels and there is no appropriate event handler that will allow us to do this automatically without compromising the performance.

@zdrawku
Copy link
Contributor

zdrawku commented Mar 11, 2019

Hey @joedementri, another approach that you may consider is to use HostListener for document transitionend and reflow the grid there.

@HostListener('document:transitionend')
  public transitionEnd() {
    this.grid.reflow();
  }

@joedementri
Copy link
Author

Thank you @zdrawku , that solution is better than the one we had previously as this one doesn't cause a ViewDestroyedError to be thrown when the navbar closes

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

No branches or pull requests

8 participants