Skip to content

Commit 13facbc

Browse files
committed
fix: show values from bookmark in form
(they are only filled in after modal was already mounted)
1 parent a25e1c5 commit 13facbc

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

development-ui/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

development-ui/src/components/EndpointModal.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useContext, useState } from "react";
1+
import { useContext, useEffect, useState } from "react";
22
import { ConfigContext } from "..";
33
import { useQuirrel } from "../hooks/useQuirrel";
44
import { connectionDetailsToHash } from "../lib/encrypted-connection-details";
@@ -33,6 +33,15 @@ export function EndpointModal() {
3333

3434
const [bookmarkUrl, setBookmarkUrl] = useState<string>();
3535

36+
useEffect(() => {
37+
if (!connectedTo) {
38+
return;
39+
}
40+
setEndpoint(connectedTo.baseUrl);
41+
setToken(connectedTo.token ?? "");
42+
setEncryptionSecret(connectedTo.encryptionSecret ?? "");
43+
}, [connectedTo]);
44+
3645
return (
3746
<>
3847
<button
@@ -155,7 +164,7 @@ export function EndpointModal() {
155164
<input
156165
placeholder="Endpoint"
157166
name="endpoint"
158-
value={endpoint}
167+
value={endpoint ?? connectedTo?.baseUrl}
159168
onChange={(evt) => setEndpoint(evt.target.value)}
160169
className="border-gray-300 placeholder-gray-500 appearance-none relative block w-full px-3 py-2 border text-gray-900 rounded-md focus:outline-none focus:shadow-outline-blue focus:border-blue-300 focus:z-10 sm:text-sm sm:leading-5"
161170
/>

0 commit comments

Comments
 (0)