Skip to content

Commit

Permalink
fix nested map
Browse files Browse the repository at this point in the history
  • Loading branch information
LunaTK committed Nov 8, 2023
1 parent a5500de commit b3d08db
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/core/src/protobuf/input/arrayLike/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { FieldOptions } from '../../../models';
import { useChildFields } from '../../../hooks';
import { getInitialValue } from '../../conversion/initial';
import ArrayLike from './ArrayLike';
import { useAutoFormCtx } from '../../../context';
import { proto2Form } from '../../conversion';

interface MapProps {
name: string;
Expand Down Expand Up @@ -35,7 +37,7 @@ const MapKeyValueInput: React.FC<{
const valueLabel = valueOptions?.label ?? 'Value';

return (
<div className="af-repeat-ele flex-1 flex flex-col my-2 p-2">
<div className="flex flex-col flex-1 p-2 my-2 af-repeat-ele">
<div className="label">
<span className="label-text">{keyLabel}</span>
</div>
Expand Down Expand Up @@ -66,11 +68,14 @@ const MapInput: React.FC<MapProps> = ({ name, field, keyType, options }) => {
name,
rules: options?.rules,
});
const ctx = useAutoFormCtx();

const add = () => {
const value = getInitialValue(field, { ignoreArrayLike: true });
const $value = proto2Form(ctx)(value, field.resolvedType, options);
append({
$key: '',
$value: getInitialValue(field, { ignoreArrayLike: true }),
$value,
});
};

Expand Down

0 comments on commit b3d08db

Please sign in to comment.