On Change Event collapses list again after data insight has been modified #997
-
Hi Community, I wrote an change event listender so that it calculates the weights for the navigation based on the sort order: window.CMS.registerEventListener({
name: 'change',
collection: 'config',
field: 'main',
handler: ({ data, collection, field }) => {
n = 1;
let currentValue = [...data.main];
currentValue.forEach(mainItem => {
mainItem.weight = n++;
});
return {...data, main: currentValue };
},
}); And this is the related collection config: - name: config
label: 'Website Configuration'
files:
- name: navigation
file: config/_default/menus.yaml
label: 'Navigation'
fields:
- name: main
label: Main Navigation
label_singular: Main Navigation Item
widget: list
collapsed: true
fields:
- name: name
label: 'Name'
hint: 'Name of the navigation item that gets displayed to the user'
widget: string
- name: url
label: 'Url'
hint: 'Absolute (e.g. https://exemple.com/page.html) or relative (e.g. ../page.html) url or anchor link (like /#contact or ./#contact).'
widget: string
- name: weight
label: Weight
hint: 'The Navigation is sorted by this number'
While it is by design that the collection is initially, collapsed the modification of the data causes that the list will be collapse after I have opened it and made modification. The code itself does what it should and adjusts the weights perfectly fine. But my expected behavior is that the list keeps uncollapsed after the change. Any ideas what could be wrong with my code? Best, Markus |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I've made #1049 to track the fix on this. |
Beta Was this translation helpful? Give feedback.
I've made #1049 to track the fix on this.