Skip to content

Commit

Permalink
Prevent fallback to bad slug value when rendering unconfigured relati…
Browse files Browse the repository at this point in the history
…onship field
  • Loading branch information
kalilsn committed Mar 3, 2025
1 parent 5c0536a commit cfa81e2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions core/app/components/forms/elements/RelatedPubsElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,11 @@ export const ConfigureRelatedValue = ({
onBlur?: () => void;
className?: string;
}) => {
const configLabel = "label" in element.config ? element.config.label : undefined;
const label = configLabel || element.label || slug;
const configLabel =
"relationshipConfig" in element.config
? element.config.relationshipConfig.label
: element.config.label;
const label = configLabel || element.label || element.slug;

const { watch, formState } = useFormContext<FormValue | FormValueSingle>();
const [isPopoverOpen, setPopoverIsOpen] = useState(false);
Expand Down
7 changes: 5 additions & 2 deletions core/app/components/pubs/PubEditor/PubEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { randomUUID } from "crypto";

import type { ProcessedPub } from "contracts";
import type { CommunitiesId, PubFieldsId, PubsId, PubTypesId, StagesId } from "db/public";
import type { CommunitiesId, PubsId, PubTypesId, StagesId } from "db/public";
import { expect } from "utils";

import type { FormElements, PubFieldElement } from "../../forms/types";
Expand Down Expand Up @@ -34,7 +34,10 @@ const RelatedPubValueElement = ({
fieldName: string;
element: PubFieldElement;
}) => {
const configLabel = "label" in element.config ? element.config.label : undefined;
const configLabel =
"relationshipConfig" in element.config
? element.config.relationshipConfig.label
: element.config.label;
const label = configLabel || element.label || element.slug;

return (
Expand Down

0 comments on commit cfa81e2

Please sign in to comment.