kgiszewski / Archetype

Archetype is an Umbraco 7 property editor that wraps other installed property editors.
https://github.com/kgiszewski/ArchetypeManual
MIT License
89 stars 54 forks source link

Updating the source scope to properly look at the ui item parent #392

Closed wkallhof closed 7 years ago

wkallhof commented 7 years ago

Steps to reproduce bug

  1. Create an archetype property editor that has a max fieldset validation on (in my case, it was 3)
  2. Add max elements (in my case 3) to that archetype on a content item in the CMS
  3. Note that you can no longer reorder / sort the elements within that archetype collection.

I noticed an issue when I had max fieldset validation turned on where when I have an archetype collection at max, I can't drag and drop within the same archetype in order to reorder the collection. I found that the code was dropping into the logic section that should be used to handle dragging and dropping between different Archetypes, which wasn't my case.

    // Special constraints for when moving between Archetypes.
    // If sourceScope is populated, we are in the first of the two updates (when
    // moving between lists, ui-sortable calls the update function twice).
    if (sourceScope && !sameScope) { 
    .... [ code was reaching here because sameScope was false ]
    }

This led me to look at how sameScope was being derived, and I found that in every case, it was false because it was comparing a child scope to a parent scope.

I updated it to compare the correct scope levels and things appear to work as expected now.

Nicholas-Westby commented 7 years ago

Could swear I fixed that exact bug recently (but in a different way). Which version of Archetype did you observe the bug in?

wkallhof commented 7 years ago

Latest Archetype on NuGet v1.13.1

Nicholas-Westby commented 7 years ago

I would recommend upgrading to 1.13.2: https://www.nuget.org/packages/Archetype/1.13.2

Nicholas-Westby commented 7 years ago

Here was the commit with the prior fix if you are curious: https://github.com/kgiszewski/Archetype/commit/155355aa0058f824687c6273ca26e2e442a4d169

wkallhof commented 7 years ago

Sigh. Turns out it wasn't the latest :)

Feel free to close.

Now to figure out how to get back the last 4 hours of my life tracking down a bug that was already fixed...

Nicholas-Westby commented 7 years ago

Wasn't time wasted! You got more familiar with the Archetype codebase, which will make future changes easier :-)

Though, I can see how that would be frustrating: https://www.youtube.com/watch?v=dGGfnLBTLdY

4minutes

:-P

wkallhof commented 7 years ago

Haha, thanks for the quick response @Nicholas-Westby

kgiszewski commented 7 years ago

Good work fellas