From 2c7aac37a21792fde14af92962df4e6fb3e0d113 Mon Sep 17 00:00:00 2001 From: Akhil Mohan Date: Wed, 20 Sep 2023 17:00:49 +0530 Subject: [PATCH] feat: resolved trailing whitespace not showing up --- .../components/v2/SecretInput/SecretInput.tsx | 40 ++++++------------- .../SecretInputRow/SecretInputRow.tsx | 2 +- 2 files changed, 13 insertions(+), 29 deletions(-) diff --git a/frontend/src/components/v2/SecretInput/SecretInput.tsx b/frontend/src/components/v2/SecretInput/SecretInput.tsx index 04fba8fe4..d7476ec57 100644 --- a/frontend/src/components/v2/SecretInput/SecretInput.tsx +++ b/frontend/src/components/v2/SecretInput/SecretInput.tsx @@ -1,5 +1,5 @@ /* eslint-disable react/no-danger */ -import { forwardRef, HTMLAttributes, useState } from "react"; +import { forwardRef, HTMLAttributes } from "react"; import sanitizeHtml, { DisallowedTagsModes } from "sanitize-html"; import { useToggle } from "@app/hooks"; @@ -34,65 +34,49 @@ const syntaxHighlight = (content?: string | null, isVisible?: boolean) => { `${${b}}` ); - return newContent; + // akhilmhdh: Dont remove this br. I am still clueless how this works but weirdly enough + // when break is added a line break works properly + return `${newContent}
`; }; -type Props = Omit, "onChange" | "onBlur"> & { +type Props = HTMLAttributes & { value?: string | null; isVisible?: boolean; isDisabled?: boolean; - onChange?: (val: string) => void; - onBlur?: () => void; }; -const commonClassName = - "font-mono text-sm caret-white border-none outline-none w-full break-all pb-4"; +const commonClassName = "font-mono text-sm caret-white border-none outline-none w-full break-all"; export const SecretInput = forwardRef( - ({ value, isVisible, onChange, onBlur, isDisabled, onFocus, ...props }, ref) => { + ({ value, isVisible, onBlur, isDisabled, onFocus, ...props }, ref) => { const [isSecretFocused, setIsSecretFocused] = useToggle(); - const [text, setText] = useState(() => value || ""); - - const update = (code: string) => { - setText(code); - if (onChange) { - onChange(code.trim()); - } - }; - - const onInput = (event: any) => { - const code = event.target.value || ""; - update(code); - }; return ( -
+
             
               
             
           
-