mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 21:00:58 +03:00
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>
This commit is contained in:
@@ -5,7 +5,7 @@ import axios from 'axios'
|
|||||||
|
|
||||||
// Material
|
// Material
|
||||||
import Autocomplete, { autocompleteClasses } from '@mui/material/Autocomplete'
|
import Autocomplete, { autocompleteClasses } from '@mui/material/Autocomplete'
|
||||||
import { Popper, CircularProgress, TextField, Box, Typography } from '@mui/material'
|
import { Popper, CircularProgress, TextField, Box, Typography, Tooltip } from '@mui/material'
|
||||||
import { useTheme, styled } from '@mui/material/styles'
|
import { useTheme, styled } from '@mui/material/styles'
|
||||||
|
|
||||||
// API
|
// API
|
||||||
@@ -175,7 +175,7 @@ export const AsyncDropdown = ({
|
|||||||
multiple={multiple}
|
multiple={multiple}
|
||||||
filterSelectedOptions={multiple}
|
filterSelectedOptions={multiple}
|
||||||
size='small'
|
size='small'
|
||||||
sx={{ mt: 1, width: '100%' }}
|
sx={{ mt: 1, width: multiple ? '90%' : '100%' }}
|
||||||
open={open}
|
open={open}
|
||||||
onOpen={() => {
|
onOpen={() => {
|
||||||
setOpen(true)
|
setOpen(true)
|
||||||
@@ -210,7 +210,8 @@ export const AsyncDropdown = ({
|
|||||||
const matchingOptions = multiple
|
const matchingOptions = multiple
|
||||||
? findMatchingOptions(options, internalValue)
|
? findMatchingOptions(options, internalValue)
|
||||||
: [findMatchingOptions(options, internalValue)].filter(Boolean)
|
: [findMatchingOptions(options, internalValue)].filter(Boolean)
|
||||||
return (
|
|
||||||
|
const textField = (
|
||||||
<TextField
|
<TextField
|
||||||
{...params}
|
{...params}
|
||||||
value={internalValue}
|
value={internalValue}
|
||||||
@@ -255,6 +256,20 @@ export const AsyncDropdown = ({
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
return !multiple ? (
|
||||||
|
textField
|
||||||
|
) : (
|
||||||
|
<Tooltip
|
||||||
|
title={
|
||||||
|
typeof internalValue === 'string' ? internalValue.replace(/[[\]"]/g, '').replace(/,/g, ', ') : internalValue
|
||||||
|
}
|
||||||
|
placement='top'
|
||||||
|
arrow
|
||||||
|
>
|
||||||
|
{textField}
|
||||||
|
</Tooltip>
|
||||||
|
)
|
||||||
}}
|
}}
|
||||||
renderOption={(props, option) => (
|
renderOption={(props, option) => (
|
||||||
<Box component='li' {...props} sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
<Box component='li' {...props} sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
||||||
|
|||||||
Reference in New Issue
Block a user