chore: improve reference variable picker user experience (#3517)

This commit is contained in:
Joel 2024-04-16 14:27:34 +08:00 committed by GitHub
parent b9fbc39754
commit f89c4203a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -208,18 +208,24 @@ const VarReferenceVars: FC<Props> = ({
const filteredVars = vars.filter((v) => {
const children = v.vars.filter(v => checkKeys([v.variable], false).isValid || v.variable.startsWith('sys.'))
return children.length > 0
}).filter((v) => {
}).filter((node) => {
if (!searchText)
return v
const children = v.vars.filter(v => v.variable.toLowerCase().includes(searchText.toLowerCase()))
return node
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
}).map((v) => {
let vars = v.vars.filter(v => checkKeys([v.variable], false).isValid || v.variable.startsWith('sys.'))
if (searchText)
}).map((node) => {
let vars = node.vars.filter(v => checkKeys([v.variable], false).isValid || v.variable.startsWith('sys.'))
if (searchText) {
const searchTextLower = searchText.toLowerCase()
if (!node.title.toLowerCase().includes(searchTextLower))
vars = vars.filter(v => v.variable.toLowerCase().includes(searchText.toLowerCase()))
}
return {
...v,
...node,
vars,
}
})
@ -266,7 +272,7 @@ const VarReferenceVars: FC<Props> = ({
}
{filteredVars.length > 0
? <div>
? <div className='max-h-[85vh] overflow-y-auto'>
{
filteredVars.map((item, i) => (