Giter VIP home page Giter VIP logo

Comments (7)

mywebstuff avatar mywebstuff commented on April 30, 2024 5

👍 I would also love if these two plugins could work together :)

from aor-dependent-input.

vedmalex avatar vedmalex commented on April 30, 2024 2

Guys! the same problem! Do anyone solve it?

from aor-dependent-input.

jamesjwarren avatar jamesjwarren commented on April 30, 2024 1

@stephanemombuleau sure here is my version of the component with these modifications https://gist.github.com/jamesjwarren/b0facf05e8a0ce5e5daa987164e571b0

from aor-dependent-input.

djhi avatar djhi commented on April 30, 2024

Please provide us a small repository reproducing the problem

from aor-dependent-input.

jamesjwarren avatar jamesjwarren commented on April 30, 2024

This is because https://github.com/MhdSyrwan/aor-embedded-array only prefixes the source property with the array element, it isn't aware of the dependsOn property of DependentInputComponent.

I was able to work around this issue with a wrapper component for DependentInput that maps the source property to dependsOn:

import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { DependentInputComponent, mapStateToProps } from 'aor-dependent-input/lib/DependentInput';


DependentInputComponent.propTypes = {
  children: PropTypes.node.isRequired,
  show: PropTypes.bool.isRequired,
  source: PropTypes.any,
  value: PropTypes.any,
  resolve: PropTypes.func,
  formName: PropTypes.string,
};

const mapStateToPropsOverride = (state, { resolve, source, value, formName }) => {
  return mapStateToProps(state, {
    // map source prop => dependsOn
    dependsOn: source,
    resolve, value, formName
  });
};

export default connect(mapStateToPropsOverride)(DependentInputComponent);

Perhaps this component should use source instead of dependsOn to be consistent with the field components and thus ease compatibility?


Update: The above doesn't totally solve the issue. It fixes the show/hiding of the fields but child fields are not correctly prefixed by EmbeddedArrayInput. I guess as they are now children of the DependantInput component.

This issue can be worked around by creating a custom DependentInputComponent that utilises the EmbeddedArrayInputFormField (aor-embedded-array/lib/mui/form/EmbeddedArrayInputFormField) in place of FormField; with the addition of the prefix property. The prefix value can be extrapolated from source. This is not ideal but I doubt there will be a nice solution without a custom component.

from aor-dependent-input.

stephanembl avatar stephanembl commented on April 30, 2024

@jamesjwarren thanks for this! Do you have a snippet available for your 'update' point? That'd be awesome. Thanks.

from aor-dependent-input.

stephanembl avatar stephanembl commented on April 30, 2024

@jamesjwarren Great, thanks :)

from aor-dependent-input.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.