Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFR] Fix ReferenceArrayInput does not work in Filters #3898

Merged
merged 1 commit into from
Oct 29, 2019

Conversation

fzaninotto
Copy link
Member

closes #3883

@fzaninotto fzaninotto added this to the 3.0.0 milestone Oct 29, 2019
return {
choices: dataStatus.choices,
error: dataStatus.error,
loaded,
loading: dataStatus.waiting,
referenceBasePath,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is never used by child components. It was not passed in 2.0. I think it comes from a bad copy/paste of ReferenceArrayField during the hooks refactoring.

@@ -115,7 +114,7 @@ const useReferenceArrayInputController = ({
// the component displaying the currently selected records may fail
const finalMatchingReferences =
matchingReferences && matchingReferences.length > 0
? matchingReferences.concat(finalReferenceRecords)
? mergeReferences(matchingReferences, finalReferenceRecords)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was creating warnings about duplicate keys: selected values that were also in the list of possible choices were displayed twice!

@@ -10,130 +10,6 @@ import LinearProgress from '../layout/LinearProgress';
import Labeled from '../input/Labeled';
import ReferenceError from './ReferenceError';

const sanitizeRestProps = ({
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just moved the View part at the bottom of the file so that the jsDoc appears first. It's easier to read that way.

@@ -262,7 +263,7 @@ const SelectArrayInput: FunctionComponent<
};

SelectArrayInput.propTypes = {
choices: PropTypes.arrayOf(PropTypes.object).isRequired,
choices: PropTypes.arrayOf(PropTypes.object),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

choices are empty when declaring the input in a form:

        <ReferenceArrayInput label="Tags" source="tags" reference="tags">
            <SelectArrayInput optionText="name" />
        </ReferenceArrayInput>

@djhi djhi merged commit 54c34d3 into next Oct 29, 2019
@djhi djhi deleted the fix-reference-array-input branch October 29, 2019 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants