{
if (isLast) {
- setPairs((pairs) => [...pairs, newPair()]);
+ setPairs((pairs) => [...pairs, newPairContainer()]);
}
}}
onDelete={isLast ? undefined : handleDelete}
@@ -81,27 +81,28 @@ export function HeaderEditor({ request, className }: Props) {
}
function FormRow({
- pair,
+ pairContainer,
onChange,
onDelete,
onFocus,
isLast,
}: {
- pair: PairWithId;
- onChange: (pair: PairWithId) => void;
- onDelete?: (pair: PairWithId) => void;
+ pairContainer: PairContainer;
+ onChange: (pair: PairContainer) => void;
+ onDelete?: (pair: PairContainer) => void;
onFocus?: () => void;
isLast?: boolean;
}) {
+ const { id } = pairContainer;
return (
onChange({ id: pair.id, header: { name } })}
+ onChange={(name) => onChange({ id, pair: { name, value: pairContainer.pair.value } })}
onFocus={onFocus}
placeholder={isLast ? 'new name' : 'name'}
useEditor={{ useTemplating: true }}
@@ -109,10 +110,10 @@ function FormRow({
onChange({ id: pair.id, header: { value } })}
+ onChange={(value) => onChange({ id, pair: { name: pairContainer.pair.name, value } })}
onFocus={onFocus}
placeholder={isLast ? 'new value' : 'value'}
useEditor={{ useTemplating: true }}
@@ -120,7 +121,8 @@ function FormRow({
{onDelete && (
onDelete(pair)}
+ title="Delete header"
+ onClick={() => onDelete(pairContainer)}
tabIndex={-1}
className={classnames('opacity-0 group-hover:opacity-100')}
/>