question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Route change event from table row click disrupts Angular change detection

See original GitHub issue

I’m submitting a … (check one with “x”)

[ x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior I have a ngx-datatable that I have setup with each row to act like a button to route to another view. On click, a route change is triggered and the view is replace by another page which should destroy the page the table is on. This seems to work great on Chrome but I’m having issues on Edge.

When Edge makes the change there is a bug where the following view isn’t rendered unless I trigger change detection manually with ChangeDetectorRef.detectChanges(). The routed view seems to only render the template with little-to-no bootstrapping of the component. The original page is still visible below the new view.

When I debug the problem it looks like the constructor is called but not the ngOnInit method. My current work-around is to run a setTimeout in the constructor and run change detection.

Another layer of strangeness is I’m only getting this bug on clicks from the second or later pages of content in the datatable. Clicks in the first rendered page seem to be fine and bootstrap the new route correctly. I’m also not getting any errors in the Edge console.

Expected behavior

Upon clicking on a row in the datatable the click handler would change the route and the following view will bootstrap correctly. The table will allow change detection to trigger regularly and process the route change appropriately.

Reproduction of the problem

I’ll try to reproduce in a plnkr but here’s an example of my current table use:

<ngx-datatable
    #datatable
    class="material striped"
    [headerHeight]="50"
    [footerHeight]="50"
    [rows]="outputRows$ | async"
    [selected]="selected"
    [selectionType]="'checkbox'"
    (select)='onSelect($event)'
    columnMode="flex"
    [selectAllRowsOnPage]="false"
    [rowHeight]="50"
    [scrollbarV]="true"
    (activate)="handleEvent($event)"
  >
    <ng-content></ng-content>
  </ngx-datatable>

What is the motivation / use case for changing the behavior?

Seems to be a serious bug on Edge.

Please tell us about your environment:

Basic Angular CLI built project served up on OSX and run on Browserstack’s Edge 16 browser. Also reproduced on Windows 10 running Edge 16.

  • Table version: 11.1.5
  • Angular version: 5.2.0
  • Browser: [ Edge 16 ]
  • Language: [TypeScript 2.4.2]

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:2
  • Comments:7

github_iconTop GitHub Comments

2reactions
hoffinationcommented, Jan 15, 2018

@molcik I also started seeing this problem occur on Chrome for my app as well. It looks like I found a fix for my app. Can you try out my fix and see if it resolves the issue on your end?

1reaction
hoffinationcommented, Feb 23, 2018

@Koslun Glad to hear that the fork was able to resolve your issue. I put in a PR in late January but the repository owner didn’t like the potential for slowdown that came with my solution. He suggested using ngZone within your callback handlers which worked well for me instead of my fork. Here’s a link to the PR:

https://github.com/swimlane/ngx-datatable/pull/1238

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular 2 routing breaks (click) handler change detection
Looks like this fix was relatively simple! For some reason when we router.navigate we lose change detection. The following is a way to...
Read more >
How to detect route change in Angular with examples
Steps to detect route change in Angular. 1. Import Router, Event, NavigationStart, NavigationEnd, NavigationError from '@angular/router'. 2.
Read more >
How to improve the performance of your Angular app - Miquido
Change Detection (CD) is Angular's mechanism for detecting data changes and automatically reacting to them. We can list the basic kind of ...
Read more >
Material Symbols and Icons - Google Fonts
Material Symbols are our newest icons consolidating over 2500 glyphs in a single font file with a wide range of design variants.
Read more >
UI Events - W3C
Relevant activation triggers for an <a> element are a click event on the text or image content of the <a> element, or a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found