From 35f8e133a9e539d66203d7afa06192875ee7a64d Mon Sep 17 00:00:00 2001 From: SagarRajput-7 <162284829+SagarRajput-7@users.noreply.github.com> Date: Wed, 25 Sep 2024 11:32:19 +0530 Subject: [PATCH] fix: dashboard variable - ux and usability fixes (#6038) * fix: dashboard variable - ux and usability fixes * fix: separarted all option, fixed tooltip handling, added clear option etc --- .../DashboardVariableSelection.styles.scss | 22 ++++++++++------ .../VariableItem.tsx | 25 ++++++++++++------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/frontend/src/container/NewDashboard/DashboardVariablesSelection/DashboardVariableSelection.styles.scss b/frontend/src/container/NewDashboard/DashboardVariablesSelection/DashboardVariableSelection.styles.scss index f7fcb83a53..6df3e79906 100644 --- a/frontend/src/container/NewDashboard/DashboardVariablesSelection/DashboardVariableSelection.styles.scss +++ b/frontend/src/container/NewDashboard/DashboardVariablesSelection/DashboardVariableSelection.styles.scss @@ -43,6 +43,15 @@ .ant-select-item { display: flex; align-items: center; + gap: 8px; + } + + .rc-virtual-list-holder { + [data-testid='option-ALL'] { + border-bottom: 1px solid var(--bg-slate-400); + padding-bottom: 12px; + margin-bottom: 8px; + } } .all-label { @@ -56,28 +65,25 @@ } .dropdown-value { - display: flex; - justify-content: space-between; - align-items: center; + display: grid; + grid-template-columns: 1fr max-content; .option-text { - max-width: 180px; padding: 0 8px; } .toggle-tag-label { padding-left: 8px; right: 40px; - font-weight: normal; - position: absolute; + font-weight: 500; } } } } .dropdown-styles { - min-width: 300px; - max-width: 350px; + min-width: 400px; + max-width: 500px; } .lightMode { diff --git a/frontend/src/container/NewDashboard/DashboardVariablesSelection/VariableItem.tsx b/frontend/src/container/NewDashboard/DashboardVariablesSelection/VariableItem.tsx index e14162d0ce..a0a444a715 100644 --- a/frontend/src/container/NewDashboard/DashboardVariablesSelection/VariableItem.tsx +++ b/frontend/src/container/NewDashboard/DashboardVariablesSelection/VariableItem.tsx @@ -62,14 +62,14 @@ interface VariableItemProps { const getSelectValue = ( selectedValue: IDashboardVariable['selectedValue'], variableData: IDashboardVariable, -): string | string[] => { +): string | string[] | undefined => { if (Array.isArray(selectedValue)) { if (!variableData.multiSelect && selectedValue.length === 1) { - return selectedValue[0]?.toString() || ''; + return selectedValue[0]?.toString(); } return selectedValue.map((item) => item.toString()); } - return selectedValue?.toString() || ''; + return selectedValue?.toString(); }; // eslint-disable-next-line sonarjs/cognitive-complexity @@ -300,7 +300,7 @@ function VariableItem({ e.stopPropagation(); e.preventDefault(); const isChecked = - variableData.allSelected || selectValue.includes(ALL_SELECT_VALUE); + variableData.allSelected || selectValue?.includes(ALL_SELECT_VALUE); if (isChecked) { handleChange([]); @@ -462,6 +462,7 @@ function VariableItem({ + {omittedValues.length} )} + allowClear > {enableSelectAll && ( @@ -500,11 +501,17 @@ function VariableItem({ {...retProps(option as string)} onClick={(e): void => handleToggle(e as any, option as string)} > - - - {option.toString()} - - + + {option.toString()} + {variableData.multiSelect && optionState.tag === option.toString() &&