Closed LuisAverhoff closed 11 months ago
Hi @LuisAverhoff.
Thanks for opening a bug for this. Would you mind creating a pr with a fix? You can reach out at gitter if you need help.
@B3zo0 Sure, I've updated this issue with a solution that seems to be working. I'm going to test my solution more thoroughly and see if there are any edge cases that I'm missing. Once that is done, I'll make a pull request.
@B3zo0 Well my solution works fine but the problem with it is that it's dependent upon the parent loading. If the user clicks on the document menu tab quickly enough, then none of the actions get listed. They would have to wait until the parent starts loading so that the proper conditions are met. Do you know of a better solution than this?
Bug
Can only create new content in the previous location that I was in.
Steps to Reproduce
1.) go http://sn-dms-demo-dev.netlify.com and login 2.) Double click on the folder called sample folder. 3.) click on the document menu that is on the left hand side to open it up. 4.) click on the new button and create any new content.
Expected Results
The new content should be created in Document_Library/Sample-Folder
Actual Results
The new content is created in Document_Library
Reason
The reason this happens is because as it's adding all the new actions to the list, the current path that it gives to the
AddNewDialog
component is the path of the old parent(Document_Library) and not the path of the new parent(Sample-Folder). Once all actions have been placed in the actions list and is ready to be rendered does it finally load the new parent but the problem is that theAddNewDialog
component is still using the old path from the old parent and will always have the wrong path after each subsequent update.Here is the function where all of this occurs. This function is in
src/components/ActionMenu/AddNewMenu.tsx
Solution
We have to check if the parent is loading and use the property parentIdOrPath as it seems to have the most up-to-date path when transitioning between parents.
Add these two properties to mapStateToProps in the AddNewMenu.tsx
then in the function getDerivedStateFromProps, all we need to do is add that additional check and cast ParentPath to a string as its type is string | number | undefined.