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

Update DragAndDropListItemContext to assign the correct id to the parent #12589

Merged
merged 7 commits into from
Apr 4, 2024

Conversation

lassopicasso
Copy link
Contributor

@lassopicasso lassopicasso commented Mar 25, 2024

Description

This PR addresses an issue where drag and drop type properties incorrectly saves/moves to the root instead of its actual parent (type).

The issue stems from the fact that the listItemContext used in the useParentId hook isn't updated with itemId, leading it to default to the rootContext.id, which represents the main data model. This might possibly due to the sequencing of updating useContext(DragAndDropListItemContext).
To solve this I added <DragAndDropListItemContext.Provider/> to the function DragAndDropProvider so it can be used on a higher level.

Also removed some code that isn't used anymore, the useStates: expandedProps and expandedDefNodes

Related Issue(s)

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)

Documentation

  • User documentation is updated with a separate linked PR in altinn-studio-docs. (if applicable)

@github-actions github-actions bot added area/data-modeling Area: Related to data models - e.g. create, edit, use data models. solution/studio/designer Issues related to the Altinn Studio Designer solution. labels Mar 25, 2024
@lassopicasso lassopicasso changed the title Add selectedTypePointer as parentId if schema tree is for a type Include selectedTypePointer as parentId when the schema tree corresponds to a type Mar 25, 2024
@lassopicasso lassopicasso marked this pull request as ready for review March 25, 2024 14:58
Copy link

codecov bot commented Mar 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.70%. Comparing base (bbce0ca) to head (27274c4).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12589      +/-   ##
==========================================
+ Coverage   88.69%   88.70%   +0.01%     
==========================================
  Files        1288     1288              
  Lines       18534    18526       -8     
  Branches     2270     2269       -1     
==========================================
- Hits        16439    16434       -5     
+ Misses       1836     1834       -2     
+ Partials      259      258       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lassopicasso lassopicasso changed the title Include selectedTypePointer as parentId when the schema tree corresponds to a type Update DragAndDropListItemContext to assign the correct id to the parent Apr 2, 2024
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

LGTM 😄

@lassopicasso lassopicasso merged commit f472d2f into main Apr 4, 2024
11 checks passed
@lassopicasso lassopicasso deleted the bug/-drag-and-drop-field-in-type branch April 4, 2024 11:28
Jondyr pushed a commit that referenced this pull request Jun 10, 2024
…arent (#12589)

* Add selectedTypePointer as parentId if schema tree is for a type

* remove console.log and rewrite comment

* add `DragAndDropListItemContext` to DragAndDropProvider

* itemId - set to optional in dragAndDropProvider
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/data-modeling Area: Related to data models - e.g. create, edit, use data models. solution/studio/designer Issues related to the Altinn Studio Designer solution.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dragging/dropping a field in a data model type moves that field out of the type and into the main data model
1 participant