diff --git a/src/Components/Inputs/Select/index.jsx b/src/Components/Inputs/Select/index.jsx index f0a1d11c0..2aa979434 100644 --- a/src/Components/Inputs/Select/index.jsx +++ b/src/Components/Inputs/Select/index.jsx @@ -18,6 +18,7 @@ import "./index.css"; * @param {string} props.items.name - The display name of each item. * @param {function} props.onChange - The function to handle onChange event. * @param {object} props.sx - The custom styles object for MUI Select component. + * @param {number} props.maxWidth - Maximum width in pixels for the select component. Enables responsive text truncation. * @returns {JSX.Element} * * @example @@ -50,6 +51,7 @@ const Select = ({ sx, name = "", labelControlSpacing = 2, + maxWidth, }) => { const theme = useTheme(); const itemStyles = { @@ -59,6 +61,13 @@ const Select = ({ margin: theme.spacing(2), }; + const responsiveMaxWidth = { + xs: `${maxWidth * 0.5}px`, + sm: `${maxWidth * 0.75}px`, + md: `${maxWidth * 0.9}px`, + lg: `${maxWidth}px`, + }; + return ( { + const selectedItem = items.find((item) => item._id === selected); + const displayName = selectedItem ? selectedItem.name : placeholder; + return ( + + {displayName} + + ); + }} > {placeholder && (