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] Introduce useChoices & useSuggestions hook #3683

Merged
merged 16 commits into from
Sep 15, 2019
Merged

[RFR] Introduce useChoices & useSuggestions hook #3683

merged 16 commits into from
Sep 15, 2019

Conversation

djhi
Copy link
Contributor

@djhi djhi commented Sep 12, 2019

This PR aims at uniforming choices handling in all components which accept choices.

It provides helper functions to get a choice value and text.

  • SelectField
  • AutocompleteArrayInput
  • AutocompleteInput
  • CheckboxGroupInput
  • RadioButtonGroupInput
  • SelectArrayInput
  • SelectInput
  • Upgrade guide
  • Documentation

It might have breaking changes for the AutocompleteArrayInput and AutocompleteInput components

Fixes #3630, #2961, #3418, #3098

@djhi djhi added this to the 3.0.0 milestone Sep 12, 2019
Copy link
Member

@fzaninotto fzaninotto left a comment

Choose a reason for hiding this comment

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

Great idea! Looking forward to the full refactoring (hope there will be more red than green).

packages/ra-core/src/form/useChoices.ts Outdated Show resolved Hide resolved
translateChoice: boolean;
}

const useChoices = ({ optionText, optionValue, translateChoice }) => {
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't it be singular, useChoice?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure yet

@djhi djhi changed the title [WIP] Introduce useChoices hook [WIP] Introduce useChoices & useSuggestions hook Sep 13, 2019
@djhi
Copy link
Contributor Author

djhi commented Sep 13, 2019

hope there will be more red than green

It probably won't as I'll keep the existing redundant tests and add almost the same on the new hooks

packages/ra-core/src/form/useSuggestions.ts Show resolved Hide resolved
packages/ra-core/src/form/useSuggestions.ts Outdated Show resolved Hide resolved
packages/ra-core/src/form/useSuggestions.ts Outdated Show resolved Hide resolved
@djhi djhi changed the title [WIP] Introduce useChoices & useSuggestions hook [RFR] Introduce useChoices & useSuggestions hook Sep 13, 2019
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