react-admin icon indicating copy to clipboard operation
react-admin copied to clipboard

<ImageField> breaks form when used as last form field

Open Natsuke opened this issue 9 years ago • 3 comments

Hi,

Just run into a problem using ImageField as last field in a form, this breaks the form display due to the float: left on the component.

export const StorageFileEdit = (props) => (
  <Edit title={<StorageFileTitle />} {...props}>
    <SimpleForm validation={createValidation(validationSchema)}>
      <DisabledInput source='id' />
      <TextInput source='name' />
      <ImageField source='url' />
    </SimpleForm>
  </Edit>
)

screenshot-0 0 0 0-3001 2017-03-07 15-06-21

Using a fields (TextField e.g.) after the ImageField one or using artifice like the code above solve the problem.

export const StorageFileEdit = (props) => (
  <Edit title={<StorageFileTitle />} {...props}>
    <SimpleForm validation={createValidation(validationSchema)}>
      <DisabledInput source='id' />
      <TextInput source='name' />
      <BlockImageField />
    </SimpleForm>
  </Edit>
)

const BlockImageField = (props) => (
  <div style={{ display: 'inline-block' }}>
    <ImageField {...props} source='url' />
  </div>
)

But I'am asking if the float: left attributes is still necessary, or if so, if there is a better way to display the ImageField whitout breaking the form.

Thanks !

Natsuke avatar Mar 07 '17 14:03 Natsuke

Good catch! I think a clear: both; in an .image-input::after element would solve the issue. I'll take a look on it later, unless you are volunteer to give it a try? :)

jpetitcolas avatar Mar 08 '17 08:03 jpetitcolas

I'll do it 👍

Natsuke avatar Mar 08 '17 09:03 Natsuke

Can't reproduce the problem anymore.

djhi avatar May 10 '17 09:05 djhi