🚸 trigger null domain change if the user switches from another domain type to free domain option to prevent the modal from registering it as a valid value

This commit is contained in:
Fred KISSIE
2025-12-17 05:22:04 +01:00
parent 3ad4a76f03
commit d3d5a1c204
4 changed files with 47 additions and 31 deletions

View File

@@ -506,12 +506,16 @@ export default function GeneralForm() {
} }
defaultFullDomain={resourceFullDomainName} defaultFullDomain={resourceFullDomainName}
onDomainChange={(res) => { onDomainChange={(res) => {
const selected = { const selected =
res === null
? null
: {
domainId: res.domainId, domainId: res.domainId,
subdomain: res.subdomain, subdomain: res.subdomain,
fullDomain: res.fullDomain, fullDomain: res.fullDomain,
baseDomain: res.baseDomain, baseDomain: res.baseDomain,
domainNamespaceId: res.domainNamespaceId domainNamespaceId:
res.domainNamespaceId
}; };
setSelectedDomain(selected); setSelectedDomain(selected);
}} }}

View File

@@ -1396,6 +1396,8 @@ export default function Page() {
<DomainPicker <DomainPicker
orgId={orgId as string} orgId={orgId as string}
onDomainChange={(res) => { onDomainChange={(res) => {
if (!res) return;
httpForm.setValue( httpForm.setValue(
"subdomain", "subdomain",
res.subdomain res.subdomain

View File

@@ -64,14 +64,16 @@ type DomainOption = {
interface DomainPickerProps { interface DomainPickerProps {
orgId: string; orgId: string;
onDomainChange?: (domainInfo: { onDomainChange?: (
domainInfo: {
domainId: string; domainId: string;
domainNamespaceId?: string; domainNamespaceId?: string;
type: "organization" | "provided"; type: "organization" | "provided";
subdomain?: string; subdomain?: string;
fullDomain: string; fullDomain: string;
baseDomain: string; baseDomain: string;
}) => void; } | null
) => void;
cols?: number; cols?: number;
hideFreeDomain?: boolean; hideFreeDomain?: boolean;
defaultFullDomain?: string | null; defaultFullDomain?: string | null;
@@ -374,16 +376,21 @@ export default function DomainPicker({
const fullDomain = sub ? `${sub}.${option.domain}` : option.domain; const fullDomain = sub ? `${sub}.${option.domain}` : option.domain;
if (option.type === "provided-search") {
onDomainChange?.(null); // prevent the modal from closing with `<subdomain>.Free Provided domain`
} else {
onDomainChange?.({ onDomainChange?.({
domainId: option.domainId || "", domainId: option.domainId || "",
domainNamespaceId: option.domainNamespaceId, domainNamespaceId: option.domainNamespaceId,
type: type: "organization",
option.type === "provided-search" ? "provided" : "organization",
subdomain: subdomain:
option.domainType !== "cname" ? sub || undefined : undefined, option.domainType !== "cname"
? sub || undefined
: undefined,
fullDomain, fullDomain,
baseDomain: option.domain baseDomain: option.domain
}); });
}
}; };
const handleProvidedDomainSelect = (option: AvailableOption) => { const handleProvidedDomainSelect = (option: AvailableOption) => {

View File

@@ -519,7 +519,10 @@ const AuthPageSettings = forwardRef<AuthPageSettingsRef, AuthPageSettingsProps>(
loginPage?.subdomain loginPage?.subdomain
} }
onDomainChange={(res) => { onDomainChange={(res) => {
const selected = { const selected =
res === null
? null
: {
domainId: res.domainId, domainId: res.domainId,
subdomain: res.subdomain, subdomain: res.subdomain,
fullDomain: res.fullDomain, fullDomain: res.fullDomain,