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

fix: propagate sortDir changes to template #1243

Merged
merged 1 commit into from
Jan 18, 2018
Merged

Conversation

ebiermann
Copy link
Contributor

What kind of change does this PR introduce? (check one with "x")

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior? (You can also link to an open issue here)
The property sortDir of header DataTableHeaderCellComponent is not updated in the template after a sort is triggered. See last comments in #808

What is the new behavior?
sortDir is propagated to cellcontext.sortdir and therefore updated when accessed via ngTemplateOutletContext inside templates

Does this PR introduce a breaking change? (check one with "x")

  • Yes
  • No

If this PR contains a breaking change, please describe the impact and migration path for existing applications: ...

Other information:

@ebiermann
Copy link
Contributor Author

ebiermann commented Jan 17, 2018

I also wanted to add a regression test to header-cell.component.spec.ts but was not able to prepare the component properly:

it('should` propagate sortDir changes to template', () => {
      component.column = {
        sortable: true
      };
      // check if initial sortDir matches template(ngTemplateOutletContext) sortDir
      const previousSortDir = component.sortDir;
      expect(component.cellContext.sortDir).toBe(component.sortDir);

      component.onSort();

      // check if sortDir changed and new sortDir matches template(ngTemplateOutletContext) sortDir
      expect(component.sortDir).not.toBe(previousSortDir);
      expect(component.cellContext.sortDir).toBe(component.sortDir);
    });

Copy link
Contributor

@amcdnl amcdnl left a comment

Choose a reason for hiding this comment

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

LGTM

@amcdnl amcdnl merged commit 022d0f4 into swimlane:master Jan 18, 2018
@ahsanahmad22
Copy link

Hi @ebiermann

I am using external column sort but I want to sort column data on first load of page, and show the correct icon for that. I have overridden the onSort(event); How I can use this method from ngInit().

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

Successfully merging this pull request may close these issues.

3 participants