Skip to content

Conversation

@Wagner3UB
Copy link
Contributor

@Wagner3UB Wagner3UB commented Oct 23, 2025

Summary
This PR fixes an issue where some table columns were missing an id key when generating column definitions dynamically from form data.

Context
The table component (based on TanStack Table, formerly known as React Table) requires every column to have a unique and non-falsy id in order to properly handle internal operations such as sorting, filtering, visibility, and rendering.
In some rare cases, the source data did not provide a valid key or identifier, causing runtime errors or rendering issues.

Without this fallback, the table configuration could break due to missing column identifiers, as id is a required field according to the TanStack Table documentation.

Reference: https://tanstack.com/table/latest/docs/guide/columns?utm_source=chatgpt.com#column-ids

@Wagner3UB Wagner3UB self-assigned this Oct 23, 2025
@mamico
Copy link
Contributor

mamico commented Oct 23, 2025

@Wagner3UB
Object.entries returns a list of 2-element arrays: [key, value], not [key, value, index].
Also, what’s the use case where the key is null or empty?

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries

@mamico
Copy link
Contributor

mamico commented Oct 23, 2025

@Wagner3UB Object.entries returns a list of 2-element arrays: [key, value], not [key, value, index].

Got it now: index is the index returned by map, not by entries.

@Wagner3UB
Copy link
Contributor Author

@Wagner3UB Object.entries returns a list of 2-element arrays: [key, value], not [key, value, index].

Got it now: index is the index returned by map, not by entries.

@mamico Yes, thank you for that. Corrected.

@mamico
Copy link
Contributor

mamico commented Oct 23, 2025

@Wagner3UB Clear. But if I understand correctly, you are fixing only the columns, not the data. In the edge case you are testing, are the columns data ever empty? If so, it might be better to exclude those columns with an empty or null key, for example (please verify):

return Object.entries(obj).filter(([key, value]) => key).map(([key, value])...

@Wagner3UB
Copy link
Contributor Author

@mamico I did the changes, the form now shows only the required columns and ignores the legacy ones.

@Wagner3UB Wagner3UB requested review from pnicolli and removed request for SaraBianchi October 24, 2025 10:59
@Wagner3UB
Copy link
Contributor Author

@pnicolli We need your approval and help to release it.

@mamico mamico self-requested a review October 24, 2025 15:50
Copy link
Contributor

@mamico mamico left a comment

Choose a reason for hiding this comment

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

OK

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