Skip to content

Commit b5e8331

Browse files
committed
removed nonce and added counter > less rerenders and only if settings changed
1 parent 8853c40 commit b5e8331

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/components/src/components/table-stateless/component.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ export class KolTableStatelessWc implements TableStatelessAPI {
8484
private fixedOffsets: number[] = [];
8585
private resizeDebounceTimeout?: ReturnType<typeof setTimeout>;
8686

87+
private settingsChangedCounter = 0;
88+
8789
@State()
8890
private tableDivElementHasScrollbar = false;
8991

@@ -228,6 +230,7 @@ export class KolTableStatelessWc implements TableStatelessAPI {
228230
public handleSettingsChange(event: CustomEvent<KoliBriTableHeaderCell[][]>) {
229231
const updatedHeaderCells = { ...this.state._headerCells, horizontal: event.detail };
230232
setState(this, '_headerCells', updatedHeaderCells);
233+
this.settingsChangedCounter++;
231234

232235
// Call the onChangeHeaderCells callback if provided
233236
if (typeof this.state._on?.[Callback.onChangeHeaderCells] === 'function') {
@@ -788,8 +791,8 @@ export class KolTableStatelessWc implements TableStatelessAPI {
788791

789792
return (
790793
<td
791-
// nonce() is needed so every cell has a unique key after a state change and gets rerenderd
792-
key={`cell-${key}-${nonce()}`}
794+
// settingsChangedCounter is needed so every cell has a unique key after a settings change and gets rerenderd
795+
key={`cell-${key}-${this.settingsChangedCounter}`}
793796
class={clsx(
794797
'kol-table__cell kol-table__cell--body',
795798
cell.textAlign && `kol-table__cell--align-${cell.textAlign}`,

0 commit comments

Comments
 (0)