Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Clear paste password on failed retry

Manav Rathi1cf38601f09f
diff --git a/web/apps/paste/src/features/paste/components/PasteViewPanel.tsx b/web/apps/paste/src/features/paste/components/PasteViewPanel.tsx
index c00627e095..2119788fbb 100644
--- a/web/apps/paste/src/features/paste/components/PasteViewPanel.tsx
+++ b/web/apps/paste/src/features/paste/components/PasteViewPanel.tsx
@@ -39,6 +39,7 @@ export const PasteViewPanel = ({
const [copied, setCopied] = useState(false);
const [password, setPassword] = useState("");
const copiedTimerRef = useRef<number | null>(null);
+ const passwordInputRef = useRef<HTMLInputElement | null>(null);
useEffect(() => {
return () => {
@@ -48,6 +49,13 @@ export const PasteViewPanel = ({
};
}, []);
+ useEffect(() => {
+ if (!passwordError) return;
+
+ setPassword("");
+ passwordInputRef.current?.focus();
+ }, [passwordError]);
+
const handlePasswordSubmit = (event: FormEvent<HTMLFormElement>) => {
event.preventDefault();
if (!password) {
@@ -92,6 +100,7 @@ export const PasteViewPanel = ({
value={password}
error={!!passwordError}
helperText={passwordError}
+ inputRef={passwordInputRef}
autoFocus
autoComplete="off"
placeholder="Password"