Describe the bug:
The forge-table-filter event fires multiple times on filter value change depending on how many times the filter elements have been rendered.
To Reproduce:
Steps to reproduce the behavior:
Go to the forge demo app table page
Enable filters
Type a value in a column with a columnConfigurationfilterDelegate of new TextFieldComponentDelegate(...) (e.g. Age)
Note the filter event data is logged once
Toggle off and back on the filters (or do anything that gets the table to re-render, like TableComponent.render())
Repeat step 3
Note the filter event data is logged twice
Expected behavior:
The filter event should only fire once on filter change.
Please complete the following information:
Forge version: 2.24.1
I have searched existing issues before creating this report? Y
Browser: All
Platform: All
OS: All
Additional context:
The cause of the issue seems to be that in _createFilterElement in table-utils.ts, delegate.onChange adds an event listener (e.g. an input event listener via onChange in text-field-component-delegate.ts), but doesn't remove the existing one. So each time _createFilterElement is called, an additional event listener accumulates on the element.
The bug occurs in any situation where the table renders and calls createFilterElement. A case where this is especially problematic is when the table renders on hiding or showing a column. Changing a filter after this will fire the event once with the old columnIndex and once with the new columnIndex.
Describe the bug: The
forge-table-filter
event fires multiple times on filter value change depending on how many times the filter elements have been rendered.To Reproduce: Steps to reproduce the behavior:
columnConfiguration
filterDelegate
ofnew TextFieldComponentDelegate(...)
(e.g. Age)TableComponent.render()
)Expected behavior: The filter event should only fire once on filter change.
Please complete the following information:
Additional context: The cause of the issue seems to be that in
_createFilterElement
intable-utils.ts
,delegate.onChange
adds an event listener (e.g. aninput
event listener viaonChange
intext-field-component-delegate.ts
), but doesn't remove the existing one. So each time_createFilterElement
is called, an additional event listener accumulates on the element.The bug occurs in any situation where the table renders and calls
createFilterElement
. A case where this is especially problematic is when the table renders on hiding or showing a column. Changing a filter after this will fire the event once with the oldcolumnIndex
and once with the newcolumnIndex
.