From f9f463cce6299daf539482068528f99e9f0d47f2 Mon Sep 17 00:00:00 2001 From: SagarRajput-7 Date: Wed, 14 May 2025 06:32:49 +0530 Subject: [PATCH] feat: show labels in widget selector --- frontend/src/components/NewSelect/CustomMultiSelect.tsx | 7 ++++++- frontend/src/components/NewSelect/types.ts | 1 + .../Variables/VariableItem/WidgetSelector.tsx | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/NewSelect/CustomMultiSelect.tsx b/frontend/src/components/NewSelect/CustomMultiSelect.tsx index ca2c5ef37862..53242380abf6 100644 --- a/frontend/src/components/NewSelect/CustomMultiSelect.tsx +++ b/frontend/src/components/NewSelect/CustomMultiSelect.tsx @@ -65,6 +65,7 @@ const CustomMultiSelect: React.FC = ({ maxTagTextLength, onDropdownVisibleChange, showIncompleteDataMessage = false, + showLabels = false, ...rest }) => { // ===== State & Refs ===== @@ -1709,7 +1710,11 @@ const CustomMultiSelect: React.FC = ({ // Custom Tag Render (needs significant updates) const tagRender = useCallback( (props: CustomTagProps): React.ReactElement => { - const { label, value, closable, onClose } = props; + const { label: labelProp, value, closable, onClose } = props; + + const label = showLabels + ? options.find((option) => option.value === value)?.label || labelProp + : labelProp; // If the display value is the special ALL value, render the ALL tag if (allOptionShown) { diff --git a/frontend/src/components/NewSelect/types.ts b/frontend/src/components/NewSelect/types.ts index 884197bc1952..5a0ce426e51d 100644 --- a/frontend/src/components/NewSelect/types.ts +++ b/frontend/src/components/NewSelect/types.ts @@ -60,4 +60,5 @@ export interface CustomMultiSelectProps onRetry?: () => void; maxTagTextLength?: number; showIncompleteDataMessage?: boolean; + showLabels?: boolean; } diff --git a/frontend/src/container/NewDashboard/DashboardSettings/Variables/VariableItem/WidgetSelector.tsx b/frontend/src/container/NewDashboard/DashboardSettings/Variables/VariableItem/WidgetSelector.tsx index 70b38d93ff84..5812deaebce6 100644 --- a/frontend/src/container/NewDashboard/DashboardSettings/Variables/VariableItem/WidgetSelector.tsx +++ b/frontend/src/container/NewDashboard/DashboardSettings/Variables/VariableItem/WidgetSelector.tsx @@ -23,6 +23,7 @@ export function WidgetSelector({ value={selectedWidgets} labelInValue onChange={(value): void => setSelectedWidgets(value as string[])} + showLabels /> ); }