mirror of
https://github.com/strapi/strapi.git
synced 2025-12-28 23:57:32 +00:00
Merge pull request #21158 from strapi/fix/webhook-edit
fix: webhook button submitting and remove row clearing
This commit is contained in:
commit
f1956fb015
@ -36,8 +36,18 @@ const HeadersInput = () => {
|
||||
|
||||
const addFieldRow = useForm('HeadersInput', (state) => state.addFieldRow);
|
||||
const removeFieldRow = useForm('HeadersInput', (state) => state.removeFieldRow);
|
||||
const setFieldValue = useForm('HeadersInput', (state) => state.onChange);
|
||||
const { value = [] } = useField<Header[]>('headers');
|
||||
|
||||
const removeRow = (index: number) => {
|
||||
// if we are removing the last row, simply clear it
|
||||
if (value.length === 1) {
|
||||
setFieldValue('headers', [{ key: '', value: '' }]);
|
||||
} else {
|
||||
removeFieldRow('headers', index);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Flex direction="column" alignItems="stretch" gap={1}>
|
||||
<DSField.Label>
|
||||
@ -47,9 +57,9 @@ const HeadersInput = () => {
|
||||
})}
|
||||
</DSField.Label>
|
||||
<Box padding={8} background="neutral100" hasRadius>
|
||||
{value.map((_, index) => {
|
||||
{value.map((val, index) => {
|
||||
return (
|
||||
<Grid.Root key={index} gap={4} padding={2}>
|
||||
<Grid.Root key={`${index}-${JSON.stringify(val.key)}`} gap={4} padding={2}>
|
||||
<Grid.Item col={6} direction="column" alignItems="stretch">
|
||||
<HeaderCombobox
|
||||
name={`headers.${index}.key`}
|
||||
@ -81,8 +91,7 @@ const HeadersInput = () => {
|
||||
padding="0.4rem"
|
||||
alignItems="center"
|
||||
justifyContent="center"
|
||||
disabled={value.length === 1}
|
||||
onClick={() => removeFieldRow('headers', index)}
|
||||
onClick={() => removeRow(index)}
|
||||
color="primary600"
|
||||
label={formatMessage(
|
||||
{
|
||||
@ -91,6 +100,7 @@ const HeadersInput = () => {
|
||||
},
|
||||
{ number: index + 1 }
|
||||
)}
|
||||
type="button"
|
||||
>
|
||||
<Minus width="0.8rem" />
|
||||
</IconButton>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user