Improve AsyncSelect layout and text overflow handling

- Add responsive width container
- Improve text truncation with tooltips
This commit is contained in:
yangdx 2025-10-17 19:10:36 +08:00
parent f555824064
commit 4c3ab58473

View file

@ -175,16 +175,25 @@ const GraphLabels = () => {
> >
<RefreshCw className={`h-4 w-4 ${isRefreshing ? 'animate-spin' : ''}`} /> <RefreshCw className={`h-4 w-4 ${isRefreshing ? 'animate-spin' : ''}`} />
</Button> </Button>
<div className="w-full min-w-[280px] max-w-[500px]">
<AsyncSelect<string> <AsyncSelect<string>
key={selectKey} // Force re-render when data changes key={selectKey} // Force re-render when data changes
className="min-w-[300px]" className="min-w-[300px]"
triggerClassName="max-h-8" triggerClassName="max-h-8 w-full overflow-hidden"
searchInputClassName="max-h-8" searchInputClassName="max-h-8"
triggerTooltip={t('graphPanel.graphLabels.selectTooltip')} triggerTooltip={t('graphPanel.graphLabels.selectTooltip')}
fetcher={fetchData} fetcher={fetchData}
renderOption={(item) => <div style={{ whiteSpace: 'pre' }}>{item}</div>} renderOption={(item) => (
<div className="truncate" title={item}>
{item}
</div>
)}
getOptionValue={(item) => item} getOptionValue={(item) => item}
getDisplayValue={(item) => <div style={{ whiteSpace: 'pre' }}>{item}</div>} getDisplayValue={(item) => (
<div className="min-w-0 flex-1 truncate text-left" title={item}>
{item}
</div>
)}
notFound={<div className="py-6 text-center text-sm">{t('graphPanel.graphLabels.noLabels')}</div>} notFound={<div className="py-6 text-center text-sm">{t('graphPanel.graphLabels.noLabels')}</div>}
ariaLabel={t('graphPanel.graphLabels.label')} ariaLabel={t('graphPanel.graphLabels.label')}
placeholder={t('graphPanel.graphLabels.placeholder')} placeholder={t('graphPanel.graphLabels.placeholder')}
@ -219,6 +228,7 @@ const GraphLabels = () => {
debounceTime={500} debounceTime={500}
/> />
</div> </div>
</div>
) )
} }