🐛 setAttributesViewGroup timing error (#16275)

* fix: "Cannot read properties of undefined (reading 'forEach')" when creating kanban view
- fixed error when `setAttributeViewGroup()` tries to access  `attrView.Views` before kanban view is added

* fix: "Failed to execute 'json' on 'Response': Unexpected end of JSON input" when converting to kanban view
- fixed error where `ChangeAttrViewLayout()` generates groups before new layout type is set, causing data structure mismatch
This commit is contained in:
NateSmyth 2025-11-03 21:01:31 -05:00 committed by GitHub
parent 8ae922cd15
commit c72f2b0167
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -721,6 +721,8 @@ func ChangeAttrViewLayout(blockID, avID string, layout av.LayoutType) (err error
return
}
view.LayoutType = newLayout
switch newLayout {
case av.LayoutTypeTable:
if view.Name == av.GetAttributeViewI18n("gallery") || view.Name == av.GetAttributeViewI18n("kanban") {
@ -788,8 +790,6 @@ func ChangeAttrViewLayout(blockID, avID string, layout av.LayoutType) (err error
setAttributeViewGroup(attrView, view, group)
}
view.LayoutType = newLayout
blockIDs := treenode.GetMirrorAttrViewBlockIDs(avID)
for _, bID := range blockIDs {
node, tree, _ := getNodeByBlockID(nil, bID)
@ -2860,10 +2860,6 @@ func addAttrViewView(avID, viewID, blockID string, layout av.LayoutType) (err er
view.Kanban.Fields = append(view.Kanban.Fields, &av.ViewKanbanField{BaseField: &av.BaseField{ID: field.ID}})
}
}
preferredGroupKey := getKanbanPreferredGroupKey(attrView)
group := &av.ViewGroup{Field: preferredGroupKey.ID}
setAttributeViewGroup(attrView, view, group)
default:
err = av.ErrWrongLayoutType
logging.LogErrorf("wrong layout type [%s] for attribute view [%s]", layout, avID)
@ -2875,6 +2871,12 @@ func addAttrViewView(avID, viewID, blockID string, layout av.LayoutType) (err er
view.ID = viewID
attrView.Views = append(attrView.Views, view)
if av.LayoutTypeKanban == layout {
preferredGroupKey := getKanbanPreferredGroupKey(attrView)
group := &av.ViewGroup{Field: preferredGroupKey.ID}
setAttributeViewGroup(attrView, view, group)
}
node, tree, _ := getNodeByBlockID(nil, blockID)
if nil == node {
logging.LogErrorf("get node by block ID [%s] failed", blockID)