aor-dependent-input icon indicating copy to clipboard operation
aor-dependent-input copied to clipboard

Delayed updates on multiple DependentInput depending on SelectInput

Open natrim opened this issue 7 years ago • 2 comments

The DependentInput has weird behaviour with defaultValue and SelectInput example below

when you click on the select it does not change value until you click on the same item again if you remove defaultValue's or if you have only one DependentInput it works ok

<SimpleForm>
  <SelectInput source="type" choices={[
    {
      id: 'pc',
      name: 'pc',
    },
    {
      id: 'server',
      name: 'server',
    },
    {
      id: 'gateway',
      name: 'gateway',
    },
    {
      id: 'acnetel',
      name: 'acnetel',
    },
  ]} defaultValue="gateway" />

        <DependentInput resolve={switchType('gateway')}>
          <TextInput source="nat" defaultValue="gateway"  />
        </DependentInput>

        <DependentInput resolve={switchType('pc')}>
          <TextInput source="not" defaultValue="pc" />
        </DependentInput>

        <DependentInput resolve={switchType('server')}>
          <TextInput source="nit" defaultValue="server" />
        </DependentInput>

        <DependentInput resolve={switchType('acnetel')}>
          <TextInput source="net" defaultValue="acntel" />
        </DependentInput>
</SimpleForm>
const switchType = (value) => (values) => {
  return values['type'] === value;
};

natrim avatar Sep 26 '17 14:09 natrim

I have exactly the same issue. Any solutions?

dane-du-plessis avatar Nov 14 '18 13:11 dane-du-plessis

update to new RA where there is not DependentInput

before updating to RA i used modified DependentInput component: gist

natrim avatar Nov 14 '18 14:11 natrim