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 bug where >2 links causes duplicates on page re-rendering #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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