🚸 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,13 +506,17 @@ export default function GeneralForm() {
}
defaultFullDomain={resourceFullDomainName}
onDomainChange={(res) => {
const selected = {
domainId: res.domainId,
subdomain: res.subdomain,
fullDomain: res.fullDomain,
baseDomain: res.baseDomain,
domainNamespaceId: res.domainNamespaceId
};
const selected =
res === null
? null
: {
domainId: res.domainId,
subdomain: res.subdomain,
fullDomain: res.fullDomain,
baseDomain: res.baseDomain,
domainNamespaceId:
res.domainNamespaceId
};
setSelectedDomain(selected);
}}
/>

View File

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

View File

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

View File

@@ -519,12 +519,15 @@ const AuthPageSettings = forwardRef<AuthPageSettingsRef, AuthPageSettingsProps>(
loginPage?.subdomain
}
onDomainChange={(res) => {
const selected = {
domainId: res.domainId,
subdomain: res.subdomain,
fullDomain: res.fullDomain,
baseDomain: res.baseDomain
};
const selected =
res === null
? null
: {
domainId: res.domainId,
subdomain: res.subdomain,
fullDomain: res.fullDomain,
baseDomain: res.baseDomain
};
setSelectedDomain(selected);
}}
/>