components icon indicating copy to clipboard operation
components copied to clipboard

[SL-GRID] sl-event is fired multiple time after initialization

Open fransdeboer opened this issue 1 year ago โ€ข 0 comments

Provide a general summary of the issue here

When a DataSource is used combined with a Grid. The sl-update event is fired multiple (4 or more) times, directly after initialization of the grid.

Consider the code below (the onUpdate method is directly executed multiple times):

this.dataSource = new ArrayDataSource(people as Person[]);
this.dataSource.addEventListener('sl-update', this.#onUpdate);

๐Ÿค” Expected Behavior?

The sl-update event should only fire if a user changes the sort order for example.

๐Ÿ˜ฏ Current Behavior

see general summary

๐Ÿ’ Possible Solution

n/a

๐Ÿ–ฅ๏ธ Steps to Reproduce

see also this demo project to reproduce this issue

  • git clone https://github.com/fransdeboer/grid-poc.git
  • execute npm i to install all packages
  • run the code with npm run dev
  • open a browser window at http://localhost:5173/
  • open the DevTools of the browser and in the console a few messages sl-update fired are logged. Where none where expected.

image

What browsers are you seeing the problem on? (only for bugs in code)

Chrome

If other, please specify.

No response

What operating system are you using?

WSL

๐Ÿ‘ค Your name

Frans de Boer

๐Ÿงข Your product/team

Magister

๐ŸŽจ Your Theme(s)

Magister

fransdeboer avatar Sep 18 '24 12:09 fransdeboer