Skip to content

Commit cfb0c1f

Browse files
committed
fix: selected option for chart values view
1 parent 2368432 commit cfb0c1f

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/components/v2/values/chartValuesDiff/ChartValuesView.component.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import {
3030
GitOpsAuthModeType,
3131
SelectPicker,
3232
SelectPickerOptionType,
33-
getSelectPickerOptionByValue,
33+
SelectPickerProps,
3434
} from '@devtron-labs/devtron-fe-common-lib'
3535
import Tippy from '@tippyjs/react'
3636
import { ReactComponent as Error } from '../../../../assets/icons/ic-warning.svg'
@@ -559,16 +559,26 @@ export const ChartValuesSelector = ({
559559
)
560560
}
561561

562-
const selectedOption = getSelectPickerOptionByValue(selectOptions, chartValues, null)
562+
const getOptionValue: SelectPickerProps<ChartValuesType>['getOptionValue'] = (option) =>
563+
`${option.value.id} ${option.value.kind}`
564+
565+
const handleChange: SelectPickerProps<ChartValuesType>['onChange'] = (selectedOption) =>
566+
handleChartValuesSelection(selectedOption.value)
567+
568+
const selectedOption = selectOptions.flatMap(groupedOption => groupedOption.options).find(option => getOptionValue(option) === getOptionValue({
569+
// Setting label null since the getOptionValue is not consuming it
570+
label: null,
571+
value: chartValues
572+
}))
563573

564574
return (
565575
<SelectPicker<ChartValuesType, false>
566576
inputId="chart-values-selector"
567577
options={selectOptions}
568578
renderMenuListFooter={renderMenuListFooter}
569-
getOptionValue={(option) => `${option.value.id} ${option.value.kind}`}
579+
getOptionValue={getOptionValue}
570580
label="Chart Values"
571-
onChange={(selectedOption) => handleChartValuesSelection(selectedOption.value)}
581+
onChange={handleChange}
572582
value={selectedOption}
573583
/>
574584
)

0 commit comments

Comments
 (0)