Skip to content

Conversation

@xenithorb
Copy link

  • Prior to this fix, any task object that had greater-than 2 links would duplicate n-1 of those links every time the page rendered.
    I made an assumption that it had something to do with Preact duplicating based on passing the entire link object to key= and it seems to work simply by removing the key= attribute altogether.
  • Also removed the unused i parameter

- Prior to this fix, any task object that had greater-than 2 links would duplicate n-1 of those links every time the page rendered. 
I made an assumption that it had something to do with Preact duplicating based on passing the entire `link` object to `key=` and it seems to work simply by removing the `key=` attribute altogether.
- Also removed the unused `i` parameter
@xenithorb
Copy link
Author

Full disclosure: I have really no actual idea why it was duplicating links in the first place and merely got lucky with this patch. I'm not a JS developer and don't understand the code very well to really understand what was happening at the Preact level for it to duplicate link items.

I do know that the data object in localStorage was fine, so it seems to be a rendering issue only.

@xenithorb
Copy link
Author

You should be able to replicate with this JSON:

{
    "group_categories": [
        {
            "title_group": "Heading", 
            "categories": [
                {
                    "tasks": [
                        {
                            "explications": "This area will start to duplicate links after a re-render", 
                            "links": [
                                {
                                    "text": "Google", 
                                    "type": "tools", 
                                    "path": "https://google.com"
                                }, 
                                {
                                    "text": "Github", 
                                    "type": "link", 
                                    "path": "https://github.com"
                                }, 
                                {
                                    "text": "Gitlab", 
                                    "type": "link", 
                                    "path": "https://gitlab.com"
                                }
                            ], 
                            "title": "Duplicate links after >2"
                        }
                    ], 
                    "title": "Task title"
                }
            ]
        }
    ], 
    "name": "Test checklist for duplicate links"
}

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.

1 participant