From 039d471af7e25626a4624f34c78503907cc5a405 Mon Sep 17 00:00:00 2001 From: Owaise Imdad Date: Sun, 2 Mar 2025 12:51:36 +0530 Subject: [PATCH 1/6] FIX-1847 implemented the logic. --- src/Components/Inputs/Select/index.jsx | 15 +++++- .../Components/OptionsHeader/index.jsx | 49 ++++++++++++------- src/Utils/Input/utils.jsx | 27 ++++++++++ 3 files changed, 72 insertions(+), 19 deletions(-) create mode 100644 src/Utils/Input/utils.jsx diff --git a/src/Components/Inputs/Select/index.jsx b/src/Components/Inputs/Select/index.jsx index f0a1d11c0..4be84b6e0 100644 --- a/src/Components/Inputs/Select/index.jsx +++ b/src/Components/Inputs/Select/index.jsx @@ -2,7 +2,7 @@ import PropTypes from "prop-types"; import { useTheme } from "@emotion/react"; import { MenuItem, Select as MuiSelect, Stack, Typography } from "@mui/material"; import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown"; - +import { renderTruncatedValue } from "../../../Utils/Input/utils"; import "./index.css"; /** @@ -50,8 +50,14 @@ const Select = ({ sx, name = "", labelControlSpacing = 2, + truncate = false, + maxTruncateLength = 15, }) => { const theme = useTheme(); + + const selectedItem = items.find((item) => item._id === value); + const displayName = selectedItem ? selectedItem.name : ""; + const itemStyles = { fontSize: "var(--env-var-font-size-medium)", color: theme.palette.primary.contrastTextTertiary, @@ -59,6 +65,10 @@ const Select = ({ margin: theme.spacing(2), }; + const renderShortValue = () => { + return renderTruncatedValue(displayName, truncate, maxTruncateLength, placeholder); + }; + return ( {placeholder && ( ; return ( @@ -27,17 +35,13 @@ const OptionsHeader = ({ direction="row" justifyContent="space-between" > - + - Incidents for + Incidents for: