Ensure seamless toggling between selected labels and the complete graph

This commit is contained in:
yangdx
2025-03-12 08:52:28 +08:00
parent fff2ef87f0
commit ee0700d288
3 changed files with 39 additions and 23 deletions

View File

@@ -50,9 +50,17 @@ const GraphLabels = () => {
[getSearchEngine]
)
const setQueryLabel = useCallback((label: string) => {
if (label.startsWith('And ') && label.endsWith(' others')) return
useSettingsStore.getState().setQueryLabel(label)
const setQueryLabel = useCallback((newLabel: string) => {
if (newLabel.startsWith('And ') && newLabel.endsWith(' others')) return
const currentLabel = useSettingsStore.getState().queryLabel
// When selecting the same label (except '*'), switch to '*'
if (newLabel === currentLabel && newLabel !== '*') {
useSettingsStore.getState().setQueryLabel('*')
} else {
useSettingsStore.getState().setQueryLabel(newLabel)
}
}, [])
return (
@@ -70,6 +78,7 @@ const GraphLabels = () => {
placeholder="Search labels..."
value={label !== null ? label : ''}
onChange={setQueryLabel}
clearable={false} // Prevent clearing value on reselect
/>
)
}