getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.28k stars 167 forks source link

Models sections: non-mutating `items` computed #6480

Closed distantnative closed 3 months ago

distantnative commented 3 months ago

Description

Summary of changes

Reasoning

In Vue 3 the page/file parameter inside the map closure will be reactive. So assigning new values will directly mutate the original object. Which is problematic in this case https://github.com/getkirby/kirby/compare/v5/develop...v5/refactor/nonmutating-modelssection-items-computed?expand=1#diff-97e5d0547fc36db8267a17f7b8e71ce28763c11dcba313d445cef261fce2ebc0R25 where we add the status button to other buttons. When the object is reactive, this adds an additional status button to the list, each time the computed prop code runs. By refactoring the code this is avoided.

Ready?