From 05e3fcadb62565d79476c89a981c2b51304a8f8a Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Thu, 24 Oct 2024 15:03:14 +0100 Subject: [PATCH] Fix --- .../PropertiesTable/PropertiesTable.tsx | 48 ++++++++++--------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/frontend/src/lib/components/PropertiesTable/PropertiesTable.tsx b/frontend/src/lib/components/PropertiesTable/PropertiesTable.tsx index b60e980849726..38a196bdf0e44 100644 --- a/frontend/src/lib/components/PropertiesTable/PropertiesTable.tsx +++ b/frontend/src/lib/components/PropertiesTable/PropertiesTable.tsx @@ -222,29 +222,33 @@ export function PropertiesTable({ if (!properties || Array.isArray(properties) || !isObject(properties)) { return [] } - let entries = Object.entries(properties).sort((a, b) => { - // if this is a posthog property we want to sort by its label - const propertyTypeMap: Record = { - [PropertyDefinitionType.Event]: TaxonomicFilterGroupType.EventProperties, - [PropertyDefinitionType.Person]: TaxonomicFilterGroupType.PersonProperties, - [PropertyDefinitionType.Group]: TaxonomicFilterGroupType.GroupsPrefix, - [PropertyDefinitionType.Session]: TaxonomicFilterGroupType.SessionProperties, - [PropertyDefinitionType.LogEntry]: TaxonomicFilterGroupType.LogEntries, - } - - const propertyType = propertyTypeMap[type] || TaxonomicFilterGroupType.EventProperties - const left = getCoreFilterDefinition(a[0], propertyType)?.label || a[0] - const right = getCoreFilterDefinition(b[0], propertyType)?.label || b[0] - - if (left < right) { - return -1 - } - if (left > right) { - return 1 - } - return 0 - }) + let entries = Object.entries(properties) + if (sortProperties) { + entries = entries.sort((a, b) => { + // if this is a posthog property we want to sort by its label + const propertyTypeMap: Record = { + [PropertyDefinitionType.Event]: TaxonomicFilterGroupType.EventProperties, + [PropertyDefinitionType.Person]: TaxonomicFilterGroupType.PersonProperties, + [PropertyDefinitionType.Group]: TaxonomicFilterGroupType.GroupsPrefix, + [PropertyDefinitionType.Session]: TaxonomicFilterGroupType.SessionProperties, + [PropertyDefinitionType.LogEntry]: TaxonomicFilterGroupType.LogEntries, + } + + const propertyType = propertyTypeMap[type] || TaxonomicFilterGroupType.EventProperties + + const left = getCoreFilterDefinition(a[0], propertyType)?.label || a[0] + const right = getCoreFilterDefinition(b[0], propertyType)?.label || b[0] + + if (left < right) { + return -1 + } + if (left > right) { + return 1 + } + return 0 + }) + } if (searchTerm) { const normalizedSearchTerm = searchTerm.toLowerCase()