Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

fix: consistent null check in ColumnMenu and conditional nextTick in saveGroupBy

Pranav Cb2c87e8df0b2
diff --git a/packages/nc-gui/components/smartsheet/header/ColumnMenu.vue b/packages/nc-gui/components/smartsheet/header/ColumnMenu.vue
index ca2d75d306..0467fcbe55 100644
--- a/packages/nc-gui/components/smartsheet/header/ColumnMenu.vue
+++ b/packages/nc-gui/components/smartsheet/header/ColumnMenu.vue
@@ -517,10 +517,11 @@ const isFilterLimitExceeded = computed(
)
const isGroupedByThisField = computed(() => {
- if (!localGroupBy.value?.length) {
- return !!gridViewCols.value[column?.value?.id]?.group_by
+ // null = no override (use synced), [] = override with empty (no grouping)
+ if (localGroupBy.value !== null) {
+ return localGroupBy.value.some((g) => g.column.id === column?.value?.id)
}
- return localGroupBy.value.some((g) => g.column.id === column?.value?.id)
+ return !!gridViewCols.value[column?.value?.id]?.group_by
})
const isGroupBySupported = computed(() => !!(fieldsToGroupBy.value || []).find((f) => f.id === column?.value?.id))
diff --git a/packages/nc-gui/components/smartsheet/toolbar/GroupByMenu.vue b/packages/nc-gui/components/smartsheet/toolbar/GroupByMenu.vue
index 46dbbd7c90..66219a201a 100644
--- a/packages/nc-gui/components/smartsheet/toolbar/GroupByMenu.vue
+++ b/packages/nc-gui/components/smartsheet/toolbar/GroupByMenu.vue
@@ -149,7 +149,7 @@ const saveGroupBy = async () => {
} else {
// Local mode: update localGroupBy ref
const allColumns = meta.value?.columns || []
- localGroupBy.value = _groupBy.value
+ const newLocalGroupBy = _groupBy.value
.filter((g) => g.fk_column_id)
.map((g, i) => ({
column: allColumns.find((c) => c.id === g.fk_column_id)!,
@@ -158,11 +158,15 @@ const saveGroupBy = async () => {
}))
.filter((g) => g.column)
+ localGroupBy.value = newLocalGroupBy
+
$e('a:group-by:update', { groupBy: _groupBy.value, local: true })
- // Wait for Vue to process the reactive updates (e.g. isGroupBy β†’ false)
- // before emitting reload, so the non-grouped grid component is mounted
- await nextTick()
+ // When transitioning from grouped to non-grouped, wait for Vue to unmount
+ // the grouped component and mount the normal grid before emitting reload
+ if (newLocalGroupBy.length === 0) {
+ await nextTick()
+ }
eventBus.emit(SmartsheetStoreEvents.GROUP_BY_RELOAD)
}