Fix #178: Adding top-level links now works correctly#196
Fix #178: Adding top-level links now works correctly#196TejInaco merged 2 commits intoeclipse-editdor:masterfrom
Conversation
…orrectly Signed-off-by: Pranav-0440 <pranavghorpade61@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #178 where adding a top-level link failed when the links property was missing or undefined in the Thing Description (TD). The dialog would remain open and console errors would occur. The fix properly initializes the links array, avoids direct mutation of state, and ensures the TD is correctly updated through the context API.
Changes:
- Fixed top-level link addition by initializing
td.linksas an empty array when missing - Refactored to use
structuredClone()to avoid direct mutation ofcontext.parsedTD - Simplified component structure and improved code readability with modern React patterns
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const [currentLinkedTd, setCurrentLinkedTd] = React.useState< | ||
| Record<string, any> | ||
| >({}); |
There was a problem hiding this comment.
Unused variable currentLinkedTd.
| const [currentLinkedTd, setCurrentLinkedTd] = React.useState< | |
| Record<string, any> | |
| >({}); |
|
@Pranav-0440 please make sure that you limit the changes seen in git diff to the problem area. there are other changes in your PR |
|
Thanks @egekorkan for the feedback. You’re right there are additional changes included. I’ll limit the diff strictly to the problem area and remove the unrelated modifications. I’ll update the PR shortly. |
Signed-off-by: Pranav-0440 <pranavghorpade61@gmail.com>
✅ Deploy Preview for editdor ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This PR fixes issue #178 where adding a top-level link
did not work and the dialog remained open.
Fix:
Tested: