perf: variable label picker scroll & focus disappear (#2135)

* fix: variable label picker scroll & focus disappear

* fix

* fix filter

* revert
This commit is contained in:
heheer
2024-07-23 18:03:53 +08:00
committed by GitHub
parent f37cdabb15
commit bf5145e632
10 changed files with 39 additions and 17 deletions

View File

@@ -292,14 +292,14 @@ async function fetchData({
function replaceVariable(text: string, obj: Record<string, any>) {
for (const [key, value] of Object.entries(obj)) {
if (value === undefined) {
text = text.replace(new RegExp(`{{${key}}}`, 'g'), UNDEFINED_SIGN);
text = text.replace(new RegExp(`{{(${key})}}`, 'g'), UNDEFINED_SIGN);
} else {
const replacement = JSON.stringify(value);
const unquotedReplacement =
replacement.startsWith('"') && replacement.endsWith('"')
? replacement.slice(1, -1)
: replacement;
text = text.replace(new RegExp(`{{${key}}}`, 'g'), unquotedReplacement);
text = text.replace(new RegExp(`{{(${key})}}`, 'g'), unquotedReplacement);
}
}
return text || '';