Skip to content

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

fix: handle removing all local group-bys and reload grid data

Pranav C56f10d36dcb5
diff --git a/packages/nc-gui/components/smartsheet/Toolbar.vue b/packages/nc-gui/components/smartsheet/Toolbar.vue
index 6a011738c1..160a35c1a6 100644
--- a/packages/nc-gui/components/smartsheet/Toolbar.vue
+++ b/packages/nc-gui/components/smartsheet/Toolbar.vue
@@ -19,8 +19,6 @@ const { isViewsLoading } = storeToRefs(useViewsStore())
const { isViewActionsEnabled } = useActionPane()
-const { isLocalMode } = useViewColumnsOrThrow()
-
const containerRef = ref<HTMLElement>()
const { width } = useElementSize(containerRef)
diff --git a/packages/nc-gui/components/smartsheet/header/ColumnMenu.vue b/packages/nc-gui/components/smartsheet/header/ColumnMenu.vue
index eb321c8bf1..ca2d75d306 100644
--- a/packages/nc-gui/components/smartsheet/header/ColumnMenu.vue
+++ b/packages/nc-gui/components/smartsheet/header/ColumnMenu.vue
@@ -517,16 +517,20 @@ const isFilterLimitExceeded = computed(
)
const isGroupedByThisField = computed(() => {
- if (localGroupBy.value.length) {
- return localGroupBy.value.some((g) => g.column.id === column?.value?.id)
+ if (!localGroupBy.value?.length) {
+ return !!gridViewCols.value[column?.value?.id]?.group_by
}
- return !!gridViewCols.value[column?.value?.id]?.group_by
+ return localGroupBy.value.some((g) => g.column.id === column?.value?.id)
})
const isGroupBySupported = computed(() => !!(fieldsToGroupBy.value || []).find((f) => f.id === column?.value?.id))
const isGroupByLimitExceeded = computed(() => {
- return !(fieldsToGroupBy.value.length && fieldsToGroupBy.value.length > groupBy.value.length && groupBy.value.length < groupByLimit)
+ return !(
+ fieldsToGroupBy.value.length &&
+ fieldsToGroupBy.value.length > groupBy.value.length &&
+ groupBy.value.length < groupByLimit
+ )
})
const filterOrGroupByThisField = (event: SmartsheetStoreEvents) => {
diff --git a/packages/nc-gui/components/smartsheet/toolbar/GroupByMenu.vue b/packages/nc-gui/components/smartsheet/toolbar/GroupByMenu.vue
index e9415070b6..a430a88143 100644
--- a/packages/nc-gui/components/smartsheet/toolbar/GroupByMenu.vue
+++ b/packages/nc-gui/components/smartsheet/toolbar/GroupByMenu.vue
@@ -53,7 +53,7 @@ const syncedGroupByEntries = computed<Group[]>(() => {
// All group-by column IDs for badge count and column filtering
const groupedByColumnIds = computed(() => {
- if (localGroupBy.value.length) {
+ if (localGroupBy.value?.length) {
return localGroupBy.value.map((g) => g.column.id).filter(Boolean)
}
return syncedGroupByEntries.value.map((g) => g.fk_column_id).filter(Boolean)
@@ -159,6 +159,10 @@ const saveGroupBy = async () => {
$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()
+
eventBus.emit(SmartsheetStoreEvents.GROUP_BY_RELOAD)
}
}
@@ -184,7 +188,7 @@ const removeFieldFromGroupBy = async (group: Group) => {
watch(open, () => {
if (open.value) {
- if (isRestrictedEditor.value && localGroupBy.value.length) {
+ if (isRestrictedEditor.value && !!localGroupBy.value?.length) {
// Restricted editors with local overrides: load from local state
_groupBy.value = localGroupBy.value.map((e, i) => ({
fk_column_id: e.column.id,
diff --git a/packages/nc-gui/composables/useViewGroupBy.ts b/packages/nc-gui/composables/useViewGroupBy.ts
index 760ef8e73e..5e3e8959c9 100644
--- a/packages/nc-gui/composables/useViewGroupBy.ts
+++ b/packages/nc-gui/composables/useViewGroupBy.ts
@@ -44,7 +44,7 @@ const [useProvideViewGroupBy, useViewGroupBy] = useInjectionState(
const { hasPersonalViewPermission } = usePersonalViewPermissions(view)
const canSyncGroupBy = hasPersonalViewPermission('groupBySync')
- const localGroupBy = ref<{ column: ColumnType; sort: string; order: number }[]>([])
+ const localGroupBy = ref<{ column: ColumnType; sort: string; order: number }[] | null>(null)
const syncedGroupBy = computed<{ column: ColumnType; sort: string; order?: number }[]>(() => {
const tempGroupBy: { column: ColumnType; sort: string; order?: number }[] = []
@@ -65,7 +65,7 @@ const [useProvideViewGroupBy, useViewGroupBy] = useInjectionState(
})
const groupBy = computed<{ column: ColumnType; sort: string; order?: number }[]>(() => {
- if (localGroupBy.value.length) {
+ if (localGroupBy.value?.length) {
return localGroupBy.value.map((e, i) => ({
column: e.column,
sort: e.sort,
@@ -549,7 +549,10 @@ const [useProvideViewGroupBy, useViewGroupBy] = useInjectionState(
watch(
() => groupBy.value.length,
async () => {
- if (!groupBy.value.length) return
+ if (!groupBy.value.length) {
+ nextTick(() => reloadViewDataHook?.trigger())
+ return
+ }
rootGroup.value.paginationData = { page: 1, pageSize: groupByGroupLimit.value }
rootGroup.value.column = {} as any
@@ -562,7 +565,7 @@ const [useProvideViewGroupBy, useViewGroupBy] = useInjectionState(
watch(
() => view.value?.id,
() => {
- localGroupBy.value = []
+ localGroupBy.value = null
},
)