mirror of
https://github.com/strapi/strapi.git
synced 2025-09-20 14:00:48 +00:00
feedback fix
This commit is contained in:
parent
ffae9fa5e7
commit
997dbb132e
@ -0,0 +1,20 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import CustomRadioGroup from '../CustomRadioGroup';
|
||||
|
||||
const BooleanRadioGroup = ({ onChange, name, ...rest }) => {
|
||||
const handleChange = e => {
|
||||
const checked = e.target.value !== 'false';
|
||||
|
||||
onChange({ target: { name, value: checked, type: 'radio' } });
|
||||
};
|
||||
|
||||
return <CustomRadioGroup {...rest} name={name} onChange={handleChange} />;
|
||||
};
|
||||
|
||||
BooleanRadioGroup.propTypes = {
|
||||
name: PropTypes.string.isRequired,
|
||||
onChange: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
export default BooleanRadioGroup;
|
@ -10,23 +10,6 @@ import { Wrapper } from './components';
|
||||
const CustomRadioGroup = ({ intlLabel, name, onChange, radios, value }) => {
|
||||
const { formatMessage } = useIntl();
|
||||
|
||||
const handleChange = e => {
|
||||
let checked;
|
||||
|
||||
if (
|
||||
name === 'multiple' ||
|
||||
name === 'single' ||
|
||||
name === 'createComponent' ||
|
||||
name === 'repeatable'
|
||||
) {
|
||||
checked = e.target.value !== 'false';
|
||||
} else {
|
||||
checked = e.target.value;
|
||||
}
|
||||
|
||||
onChange({ target: { name, value: checked, type: 'radio' } });
|
||||
};
|
||||
|
||||
return (
|
||||
<Stack size={2}>
|
||||
<Text textColor="neutral800" htmlFor={name} small bold as="label">
|
||||
@ -43,7 +26,7 @@ const CustomRadioGroup = ({ intlLabel, name, onChange, radios, value }) => {
|
||||
checked={radio.value === value}
|
||||
value={radio.value}
|
||||
key={radio.value}
|
||||
onChange={handleChange}
|
||||
onChange={onChange}
|
||||
type="radio"
|
||||
/>
|
||||
<Box className="option" padding={4}>
|
||||
|
@ -41,7 +41,7 @@ const baseForm = {
|
||||
defaultMessage: 'Type',
|
||||
},
|
||||
name: 'repeatable',
|
||||
type: 'radio-group',
|
||||
type: 'boolean-radio-group',
|
||||
size: 12,
|
||||
radios: [
|
||||
{
|
||||
@ -180,7 +180,7 @@ const baseForm = {
|
||||
},
|
||||
name: 'multiple',
|
||||
size: 12,
|
||||
type: 'radio-group',
|
||||
type: 'boolean-radio-group',
|
||||
radios: [
|
||||
{
|
||||
title: {
|
||||
|
@ -6,7 +6,7 @@ const componentField = {
|
||||
defaultMessage: 'Type',
|
||||
},
|
||||
name: 'createComponent',
|
||||
type: 'radio-group',
|
||||
type: 'boolean-radio-group',
|
||||
size: 12,
|
||||
radios: [
|
||||
{
|
||||
|
@ -32,6 +32,7 @@ import DraftAndPublishToggle from '../DraftAndPublishToggle';
|
||||
import FormModalHeader from '../FormModalHeader';
|
||||
|
||||
import BooleanDefaultValueSelect from '../BooleanDefaultValueSelect';
|
||||
import BooleanRadioGroup from '../BooleanRadioGroup';
|
||||
import CheckboxWithNumberField from '../CheckboxWithNumberField';
|
||||
import CustomRadioGroup from '../CustomRadioGroup';
|
||||
import ContentTypeRadioGroup from '../ContentTypeRadioGroup';
|
||||
@ -864,6 +865,7 @@ const FormModal = () => {
|
||||
const genericInputProps = {
|
||||
customInputs: {
|
||||
'allowed-types-select': AllowedTypesSelect,
|
||||
'boolean-radio-group': BooleanRadioGroup,
|
||||
'checkbox-with-number-field': CheckboxWithNumberField,
|
||||
'component-icon-picker': ComponentIconPicker,
|
||||
'content-type-radio-group': ContentTypeRadioGroup,
|
||||
|
Loading…
x
Reference in New Issue
Block a user