Skip to content

Commit 15dd283

Browse files
fix: Modify the style of the AsyncDropdown component (#4642)
* bugfix/Modify the style of the AsyncDropdown component to adjust its width based on the multiple property. #4641 * style: fix linter warning * style: fix linter warning * style: fix linter warning --------- Co-authored-by: 강나훈 <nahoon.kang@mnc.ai>
1 parent 8ba1a09 commit 15dd283

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

packages/ui/src/ui-component/dropdown/AsyncDropdown.jsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import axios from 'axios'
55

66
// Material
77
import Autocomplete, { autocompleteClasses } from '@mui/material/Autocomplete'
8-
import { Popper, CircularProgress, TextField, Box, Typography } from '@mui/material'
8+
import { Popper, CircularProgress, TextField, Box, Typography, Tooltip } from '@mui/material'
99
import { useTheme, styled } from '@mui/material/styles'
1010

1111
// API
@@ -175,7 +175,7 @@ export const AsyncDropdown = ({
175175
multiple={multiple}
176176
filterSelectedOptions={multiple}
177177
size='small'
178-
sx={{ mt: 1, width: '100%' }}
178+
sx={{ mt: 1, width: multiple ? '90%' : '100%' }}
179179
open={open}
180180
onOpen={() => {
181181
setOpen(true)
@@ -210,7 +210,8 @@ export const AsyncDropdown = ({
210210
const matchingOptions = multiple
211211
? findMatchingOptions(options, internalValue)
212212
: [findMatchingOptions(options, internalValue)].filter(Boolean)
213-
return (
213+
214+
const textField = (
214215
<TextField
215216
{...params}
216217
value={internalValue}
@@ -255,6 +256,20 @@ export const AsyncDropdown = ({
255256
}}
256257
/>
257258
)
259+
260+
return !multiple ? (
261+
textField
262+
) : (
263+
<Tooltip
264+
title={
265+
typeof internalValue === 'string' ? internalValue.replace(/[[\]"]/g, '').replace(/,/g, ', ') : internalValue
266+
}
267+
placement='top'
268+
arrow
269+
>
270+
{textField}
271+
</Tooltip>
272+
)
258273
}}
259274
renderOption={(props, option) => (
260275
<Box component='li' {...props} sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>

0 commit comments

Comments
 (0)