From 9746e1f6af9718c98446e8a62f5697a25f8963b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 2 Jul 2020 07:59:18 +0200 Subject: [PATCH] PanelEdit: Remove field label for single item categories (#25990) * FieldConfig: Remove field label for single item categories * Update public/app/features/dashboard/components/PanelEditor/FieldConfigEditor.tsx Co-authored-by: Alex Khomenko Co-authored-by: Alex Khomenko --- .../components/PanelEditor/FieldConfigEditor.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/public/app/features/dashboard/components/PanelEditor/FieldConfigEditor.tsx b/public/app/features/dashboard/components/PanelEditor/FieldConfigEditor.tsx index 43b19ecb1ec..feed3102f59 100644 --- a/public/app/features/dashboard/components/PanelEditor/FieldConfigEditor.tsx +++ b/public/app/features/dashboard/components/PanelEditor/FieldConfigEditor.tsx @@ -1,4 +1,4 @@ -import React, { useCallback } from 'react'; +import React, { useCallback, ReactNode } from 'react'; import cloneDeep from 'lodash/cloneDeep'; import { DataFrame, @@ -171,12 +171,17 @@ export const DefaultFieldConfigEditor: React.FC = ({ data, onChange, conf : undefined : (defaults as any)[item.path]; - const label = ( + let label: ReactNode | undefined = ( ); + // hide label if there is only one item and category name is same as item, name + if (categoryItemCount === 1 && item.category?.[0] === item.name) { + label = undefined; + } + return (