mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-14 06:15:53 +08:00
chore: improve reference variable picker user experience (#3517)
This commit is contained in:
parent
b9fbc39754
commit
f89c4203a0
@ -208,18 +208,24 @@ const VarReferenceVars: FC<Props> = ({
|
|||||||
const filteredVars = vars.filter((v) => {
|
const filteredVars = vars.filter((v) => {
|
||||||
const children = v.vars.filter(v => checkKeys([v.variable], false).isValid || v.variable.startsWith('sys.'))
|
const children = v.vars.filter(v => checkKeys([v.variable], false).isValid || v.variable.startsWith('sys.'))
|
||||||
return children.length > 0
|
return children.length > 0
|
||||||
}).filter((v) => {
|
}).filter((node) => {
|
||||||
if (!searchText)
|
if (!searchText)
|
||||||
return v
|
return node
|
||||||
const children = v.vars.filter(v => v.variable.toLowerCase().includes(searchText.toLowerCase()))
|
const children = node.vars.filter((v) => {
|
||||||
|
const searchTextLower = searchText.toLowerCase()
|
||||||
|
return v.variable.toLowerCase().includes(searchTextLower) || node.title.toLowerCase().includes(searchTextLower)
|
||||||
|
})
|
||||||
return children.length > 0
|
return children.length > 0
|
||||||
}).map((v) => {
|
}).map((node) => {
|
||||||
let vars = v.vars.filter(v => checkKeys([v.variable], false).isValid || v.variable.startsWith('sys.'))
|
let vars = node.vars.filter(v => checkKeys([v.variable], false).isValid || v.variable.startsWith('sys.'))
|
||||||
if (searchText)
|
if (searchText) {
|
||||||
vars = vars.filter(v => v.variable.toLowerCase().includes(searchText.toLowerCase()))
|
const searchTextLower = searchText.toLowerCase()
|
||||||
|
if (!node.title.toLowerCase().includes(searchTextLower))
|
||||||
|
vars = vars.filter(v => v.variable.toLowerCase().includes(searchText.toLowerCase()))
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...v,
|
...node,
|
||||||
vars,
|
vars,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -266,7 +272,7 @@ const VarReferenceVars: FC<Props> = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
{filteredVars.length > 0
|
{filteredVars.length > 0
|
||||||
? <div>
|
? <div className='max-h-[85vh] overflow-y-auto'>
|
||||||
|
|
||||||
{
|
{
|
||||||
filteredVars.map((item, i) => (
|
filteredVars.map((item, i) => (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user