Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: table/list keyAttribute error if not unique (fixes SFKUI-6936) #284

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

NicklasWei
Copy link
Contributor

Lägger till att FList, FDataTable och FInteractiveTable kollar så att keyAttribute faktiskt är unikt när items/rows ändras. Och om inte, kastar fel.

Copy link

PR Preview Action v1.6.0

🚀 View preview at
https://Forsakringskassan.github.io/designsystem/pr-preview/pr-284/

Built to branch gh-pages at 2025-02-16 21:13 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

for (const row of this.rows) {
const rowKey = String(row[this.keyAttribute]);
if (seenKeys[rowKey]) {
const index = this.rows.indexOf(row);
Copy link
Contributor

Choose a reason for hiding this comment

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

Väldigt sällan jag rekommenderar .forEach() men här känns som en ok fall:

this.rows.forEach((row, index) => {

});

Så slipper vi scanna tabellen två gånger för att hitta index (en gång för for-slingar, en gång för indexOf)

Alternativt

for (const index in this.rows) {
    const row = this.rows[index];
}

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.

4 participants