Fix label selection with leading/trailing whitespace
• Fix AsyncSelect value trimming issue • Preserve whitespace in label display • Use safe keys for command items • Add GraphControl dependency fix • Add debug logging for graph labels
This commit is contained in:
parent
3c0ce9e38d
commit
25b5d176cd
4 changed files with 36 additions and 19 deletions
|
|
@ -66,6 +66,11 @@ def create_graph_routes(rag, api_key: Optional[str] = None):
|
|||
Dict[str, List[str]]: Knowledge graph for label
|
||||
"""
|
||||
try:
|
||||
# Log the label parameter to check for leading spaces
|
||||
logger.debug(
|
||||
f"get_knowledge_graph called with label: '{label}' (length: {len(label)}, repr: {repr(label)})"
|
||||
)
|
||||
|
||||
return await rag.get_knowledge_graph(
|
||||
node_label=label,
|
||||
max_depth=max_depth,
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ const GraphControl = ({ disableHoverEffect }: { disableHoverEffect?: boolean })
|
|||
|
||||
// Register the events
|
||||
registerEvents(events)
|
||||
}, [registerEvents, enableEdgeEvents])
|
||||
}, [registerEvents, enableEdgeEvents, sigma])
|
||||
|
||||
/**
|
||||
* When edge size settings change, recalculate edge sizes and refresh the sigma instance
|
||||
|
|
|
|||
|
|
@ -140,9 +140,9 @@ const GraphLabels = () => {
|
|||
searchInputClassName="max-h-8"
|
||||
triggerTooltip={t('graphPanel.graphLabels.selectTooltip')}
|
||||
fetcher={fetchData}
|
||||
renderOption={(item) => <div>{item}</div>}
|
||||
renderOption={(item) => <div style={{ whiteSpace: 'pre' }}>{item}</div>}
|
||||
getOptionValue={(item) => item}
|
||||
getDisplayValue={(item) => <div>{item}</div>}
|
||||
getDisplayValue={(item) => <div style={{ whiteSpace: 'pre' }}>{item}</div>}
|
||||
notFound={<div className="py-6 text-center text-sm">No labels found</div>}
|
||||
label={t('graphPanel.graphLabels.label')}
|
||||
placeholder={t('graphPanel.graphLabels.placeholder')}
|
||||
|
|
|
|||
|
|
@ -245,22 +245,34 @@ export function AsyncSelect<T>({
|
|||
</CommandEmpty>
|
||||
))}
|
||||
<CommandGroup>
|
||||
{options.map((option) => (
|
||||
<CommandItem
|
||||
key={getOptionValue(option)}
|
||||
value={getOptionValue(option)}
|
||||
onSelect={handleSelect}
|
||||
className="truncate"
|
||||
>
|
||||
{renderOption(option)}
|
||||
<Check
|
||||
className={cn(
|
||||
'ml-auto h-3 w-3',
|
||||
selectedValue === getOptionValue(option) ? 'opacity-100' : 'opacity-0'
|
||||
)}
|
||||
/>
|
||||
</CommandItem>
|
||||
))}
|
||||
{options.map((option, index) => {
|
||||
const optionValue = getOptionValue(option);
|
||||
// Use index as a safe value that won't be trimmed by cmdk
|
||||
const safeValue = `option-${index}-${optionValue.length}`;
|
||||
|
||||
return (
|
||||
<CommandItem
|
||||
key={optionValue}
|
||||
value={safeValue}
|
||||
onSelect={(selectedSafeValue) => {
|
||||
// Extract the original value from the safe value
|
||||
const selectedIndex = parseInt(selectedSafeValue.split('-')[1]);
|
||||
const originalValue = getOptionValue(options[selectedIndex]);
|
||||
console.log(`CommandItem onSelect: safeValue='${selectedSafeValue}', originalValue='${originalValue}' (length: ${originalValue.length})`);
|
||||
handleSelect(originalValue);
|
||||
}}
|
||||
className="truncate"
|
||||
>
|
||||
{renderOption(option)}
|
||||
<Check
|
||||
className={cn(
|
||||
'ml-auto h-3 w-3',
|
||||
selectedValue === optionValue ? 'opacity-100' : 'opacity-0'
|
||||
)}
|
||||
/>
|
||||
</CommandItem>
|
||||
);
|
||||
})}
|
||||
</CommandGroup>
|
||||
</CommandList>
|
||||
</Command>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue