mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-02 08:09:10 +00:00
Enter key handling & hostname field reset in resource create
This commit is contained in:
@@ -630,19 +630,29 @@ export default function Page() {
|
||||
defaultValue={row.original.ip}
|
||||
className="min-w-[150px]"
|
||||
onBlur={(e) => {
|
||||
const parsed = parseHostTarget(e.target.value);
|
||||
const input = e.target.value.trim();
|
||||
const hasProtocol = /^(https?|h2c):\/\//.test(input);
|
||||
const hasPort = /:\d+(?:\/|$)/.test(input);
|
||||
|
||||
if (parsed) {
|
||||
updateTarget(row.original.targetId, {
|
||||
...row.original,
|
||||
method: parsed.protocol,
|
||||
ip: parsed.host,
|
||||
port: parsed.port ? Number(parsed.port) : undefined,
|
||||
});
|
||||
if (hasProtocol || hasPort) {
|
||||
const parsed = parseHostTarget(input);
|
||||
if (parsed) {
|
||||
updateTarget(row.original.targetId, {
|
||||
...row.original,
|
||||
method: hasProtocol ? parsed.protocol : row.original.method,
|
||||
ip: parsed.host,
|
||||
port: hasPort ? parsed.port : row.original.port
|
||||
});
|
||||
} else {
|
||||
updateTarget(row.original.targetId, {
|
||||
...row.original,
|
||||
ip: input
|
||||
});
|
||||
}
|
||||
} else {
|
||||
updateTarget(row.original.targetId, {
|
||||
...row.original,
|
||||
ip: e.target.value,
|
||||
ip: input
|
||||
});
|
||||
}
|
||||
}}
|
||||
@@ -744,6 +754,11 @@ export default function Page() {
|
||||
<SettingsSectionForm>
|
||||
<Form {...baseForm}>
|
||||
<form
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter") {
|
||||
e.preventDefault(); // block default enter refresh
|
||||
}
|
||||
}}
|
||||
className="space-y-4"
|
||||
id="base-resource-form"
|
||||
>
|
||||
@@ -856,6 +871,11 @@ export default function Page() {
|
||||
<SettingsSectionForm>
|
||||
<Form {...tcpUdpForm}>
|
||||
<form
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter") {
|
||||
e.preventDefault(); // block default enter refresh
|
||||
}
|
||||
}}
|
||||
className="space-y-4"
|
||||
id="tcp-udp-settings-form"
|
||||
>
|
||||
@@ -1204,11 +1224,21 @@ export default function Page() {
|
||||
id="ip"
|
||||
{...field}
|
||||
onBlur={(e) => {
|
||||
const parsed = parseHostTarget(e.target.value);
|
||||
if (parsed) {
|
||||
addTargetForm.setValue("method", parsed.protocol);
|
||||
addTargetForm.setValue("ip", parsed.host);
|
||||
addTargetForm.setValue("port", parsed.port);
|
||||
const input = e.target.value.trim();
|
||||
const hasProtocol = /^(https?|h2c):\/\//.test(input);
|
||||
const hasPort = /:\d+(?:\/|$)/.test(input);
|
||||
|
||||
if (hasProtocol || hasPort) {
|
||||
const parsed = parseHostTarget(input);
|
||||
if (parsed) {
|
||||
if (hasProtocol || !addTargetForm.getValues("method")) {
|
||||
addTargetForm.setValue("method", parsed.protocol);
|
||||
}
|
||||
addTargetForm.setValue("ip", parsed.host);
|
||||
if (hasPort || !addTargetForm.getValues("port")) {
|
||||
addTargetForm.setValue("port", parsed.port);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
field.onBlur();
|
||||
}
|
||||
|
||||
@@ -620,6 +620,11 @@ WantedBy=default.target`
|
||||
<SettingsSectionForm>
|
||||
<Form {...form}>
|
||||
<form
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter") {
|
||||
e.preventDefault(); // block default enter refresh
|
||||
}
|
||||
}}
|
||||
className="space-y-4"
|
||||
id="create-site-form"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user