diff --git a/src/frontend/components/property-type/array/edit.tsx b/src/frontend/components/property-type/array/edit.tsx index 9ebc1af75..bf6e4a4cb 100644 --- a/src/frontend/components/property-type/array/edit.tsx +++ b/src/frontend/components/property-type/array/edit.tsx @@ -20,14 +20,12 @@ type ItemRendererProps = { } const ItemRenderer: React.FC = (props) => { - const { ItemComponent, property, onDelete, index, record, isDraggable } = props - const uniqueDraggableId = window.btoa(unescape(encodeURIComponent(`${JSON.stringify(flat.get(record.params, property.path))}-${property.path}`))) + const { ItemComponent, property, onDelete, index, isDraggable } = props return ( {(provided): JSX.Element => ( diff --git a/src/frontend/components/property-type/currency/currency-input-wrapper.tsx b/src/frontend/components/property-type/currency/currency-input-wrapper.tsx deleted file mode 100644 index bf17e4e6d..000000000 --- a/src/frontend/components/property-type/currency/currency-input-wrapper.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import { CurrencyInput, CurrencyInputProps } from '@adminjs/design-system' -import React, { FC, useState } from 'react' - -import allowOverride from '../../../hoc/allow-override' - -export type CurrencyInputWrapperProps = { - id: string; - initial: string; - options?: CurrencyInputProps - // eslint-disable-next-line @typescript-eslint/ban-types - onChange: (value: string | undefined) => void; -} - -const CurrencyInputWrapper: FC = (props) => { - const { id, initial, onChange, options } = props - const [value, setValue] = useState(initial) - const onValueChange = (currentValue: string | undefined): void => { - setValue(currentValue) - onChange(currentValue) - } - return ( - - ) -} - -const OverridableCurrencyInputWrapper = allowOverride(CurrencyInputWrapper, 'CurrencyPropertyInputWrapper') - -export { - OverridableCurrencyInputWrapper as CurrencyInputWrapper, - OverridableCurrencyInputWrapper as default, -} diff --git a/src/frontend/components/property-type/currency/edit.tsx b/src/frontend/components/property-type/currency/edit.tsx index 355ae9b96..5c5a2d416 100644 --- a/src/frontend/components/property-type/currency/edit.tsx +++ b/src/frontend/components/property-type/currency/edit.tsx @@ -1,24 +1,25 @@ -import { CurrencyInputProps, FormGroup, FormMessage } from '@adminjs/design-system' +import { CurrencyInput, FormGroup, FormMessage } from '@adminjs/design-system' import React, { FC, memo } from 'react' import { EditPropertyProps } from '../base-property-props' import { recordPropertyIsEqual } from '../record-property-is-equal' import { PropertyLabel } from '../utils/property-label' import allowOverride from '../../../hoc/allow-override' -import { CurrencyInputWrapper } from './currency-input-wrapper' const Edit: FC = (props) => { const { onChange, property, record } = props - const propValue = record.params?.[property.path] ?? '' + const propValue = record.params[property.path] const error = record.errors?.[property.path] return ( - onChange(property.path, value)} + name={property.path} + value={propValue ?? ''} + placeholder="" + onValueChange={(value) => onChange(property.path, value)} + {...property.props} /> {error && error.message} diff --git a/src/frontend/components/property-type/default-type/edit.tsx b/src/frontend/components/property-type/default-type/edit.tsx index 86518aabf..e8f8b4e5e 100644 --- a/src/frontend/components/property-type/default-type/edit.tsx +++ b/src/frontend/components/property-type/default-type/edit.tsx @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/explicit-function-return-type */ -import React, { FC, useState, memo, useEffect } from 'react' +import React, { FC, memo } from 'react' import { Input, FormMessage, FormGroup, Select } from '@adminjs/design-system' import { EditPropertyProps } from '../base-property-props' @@ -43,26 +43,19 @@ const SelectEdit: FC = (props) => { const TextEdit: FC = (props) => { const { property, record, onChange } = props - const propValue = record.params?.[property.path] ?? '' - const [value, setValue] = useState(propValue) - - useEffect(() => { - if (value !== propValue) { - setValue(propValue) - } - }, [propValue]) + const propValue = record.params[property.path] return ( setValue(e.target.value)} - onBlur={() => onChange(property.path, value)} - // handle clicking ENTER - onKeyDown={(e) => e.keyCode === 13 && onChange(property.path, value)} - value={value} + onChange={(e: React.ChangeEvent) => { + onChange(property.path, e.target.value) + }} + value={propValue ?? ''} disabled={property.isDisabled} + placeholder={propValue === null ? '' : undefined} {...property.props} /> )