Skip to content

Commit

Permalink
fix: add click listener in constructor to ensure listener order (#7184)…
Browse files Browse the repository at this point in the history
… (#7206)
  • Loading branch information
ugur-vaadin authored Mar 14, 2024
1 parent e258af3 commit b6f98ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/grid/src/vaadin-grid-tree-toggle-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,8 @@ export const GridTreeToggleMixin = (superClass) =>
};
}

/** @protected */
ready() {
super.ready();

constructor() {
super();
this.addEventListener('click', (e) => this._onClick(e));
}

Expand Down
11 changes: 11 additions & 0 deletions packages/grid/test/tree-toggle.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ describe('tree toggle', () => {

toggle.removeEventListener('expanded-changed', spy);
});

it('should have the correct expanded state on listener invocation', (done) => {
toggle = document.createElement('vaadin-grid-tree-toggle');
toggle.addEventListener('click', () => {
expect(toggle.expanded).to.be.true;
done();
});
const wrapper = fixtureSync('<div></div>');
wrapper.append(toggle);
click(toggle);
});
});

describe('level', () => {
Expand Down

0 comments on commit b6f98ee

Please sign in to comment.