Skip to content

Commit

Permalink
fix: Unwrap optional map values (#1182)
Browse files Browse the repository at this point in the history
  • Loading branch information
RohinBhargava authored Jul 23, 2024
1 parent c367376 commit 5cd2a75
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/ui/app/src/api-playground/form/PlaygroundMapForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { FernButton } from "@fern-ui/components";
import { isPlainObject } from "@fern-ui/core-utils";
import { Cross1Icon, PlusIcon } from "@radix-ui/react-icons";
import { memo, useCallback, useEffect, useState } from "react";
import { ResolvedTypeDefinition, ResolvedTypeShape } from "../../resolver/types";
import { ResolvedTypeDefinition, ResolvedTypeShape, unwrapOptional } from "../../resolver/types";
import { getDefaultValueForType, unknownToString } from "../utils";
import { PlaygroundTypeReferenceForm } from "./PlaygroundTypeReferenceForm";

Expand Down Expand Up @@ -66,6 +66,7 @@ export const PlaygroundMapForm = memo<PlaygroundMapFormProps>((props) => {
const handleRemoveItem = useCallback((idx: number) => {
setInternalState((oldArray) => [...oldArray.slice(0, idx), ...oldArray.slice(idx + 1)]);
}, []);

return (
<>
{internalState.length > 0 && (
Expand Down Expand Up @@ -94,7 +95,7 @@ export const PlaygroundMapForm = memo<PlaygroundMapFormProps>((props) => {
<span className="t-muted text-xs">{"value"}</span>
<PlaygroundTypeReferenceForm
id={`${id}[${idx}].value`}
shape={valueShape}
shape={unwrapOptional(valueShape, types)}
value={item.value}
onChange={(newValue) => handleChangeValue(idx, newValue)}
types={types}
Expand Down

0 comments on commit 5cd2a75

Please sign in to comment.