Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

adjustment: finalized InfisicalSecretInput

Sheen Capadnganb135ba263c91
diff --git a/frontend/src/components/v2/InfisicalSecretInput/InfisicalSecretInput.tsx b/frontend/src/components/v2/InfisicalSecretInput/InfisicalSecretInput.tsx
index 965a247611..9cb0a0bbc9 100644
--- a/frontend/src/components/v2/InfisicalSecretInput/InfisicalSecretInput.tsx
+++ b/frontend/src/components/v2/InfisicalSecretInput/InfisicalSecretInput.tsx
@@ -1,5 +1,5 @@
/* eslint-disable react/no-danger */
-import React, { forwardRef, TextareaHTMLAttributes, useRef, useState } from "react";
+import React, { forwardRef, TextareaHTMLAttributes, useEffect, useRef, useState } from "react";
import { twMerge } from "tailwind-merge";
import {
@@ -97,15 +97,23 @@ export const InfisicalSecretInput = forwardRef<HTMLTextAreaElement, Props>(
const [referenceKey, setReferenceKey] = useState<string>();
const [lastCaretPos, setLastCaretPos] = useState<number>(0);
+ useEffect(() => {
+ setValue(propValue as string);
+ }, [propValue]);
+
const isCaretInsideReference = (str: string, start: number) => {
- const match = [...str.matchAll(REGEX_SECRET_REFERENCE_FIND)].find(
- (entry) =>
- typeof entry?.index !== "undefined" &&
- entry.index <= start &&
- start < entry.index + entry[0].length
- );
+ if (str) {
+ const match = [...str.matchAll(REGEX_SECRET_REFERENCE_FIND)].find(
+ (entry) =>
+ typeof entry?.index !== "undefined" &&
+ entry.index <= start &&
+ start < entry.index + entry[0].length
+ );
+
+ return match || null;
+ }
- return match || null;
+ return null;
};
const setCaretPos = (caretPos: number) => {
@@ -299,7 +307,7 @@ export const InfisicalSecretInput = forwardRef<HTMLTextAreaElement, Props>(
if (!showReferencePopup) setIsSecretFocused.off();
}}
{...props}
- value={value}
+ value={value || ""}
readOnly={isReadOnly}
/>
</div>
diff --git a/frontend/src/views/SecretOverviewPage/components/SecretOverviewTableRow/SecretEditRow.tsx b/frontend/src/views/SecretOverviewPage/components/SecretOverviewTableRow/SecretEditRow.tsx
index 5dd8db4d61..58eaf429fc 100644
--- a/frontend/src/views/SecretOverviewPage/components/SecretOverviewTableRow/SecretEditRow.tsx
+++ b/frontend/src/views/SecretOverviewPage/components/SecretOverviewTableRow/SecretEditRow.tsx
@@ -100,6 +100,7 @@ export const SecretEditRow = ({
<InfisicalSecretInput
{...field}
value={field.value as string}
+ key="secret-input"
isVisible={isVisible}
secretPath={secretPath}
environment={environment}