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

Add prop pickedOrder for new selected initial order #126

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

xipasduarte
Copy link
Contributor

@xipasduarte xipasduarte commented Jul 12, 2022

When selecting a new item for the list, the only option was to have the
item pushed to the top. This adds support for two other sorts:

  • end pushes the item to end of the content array
  • function if the user defines a function they may control where to push
    the new item
  • start becomes the default value, keeping the current behavior

Description of the Change

When selecting a new item for the list, depending on the value of pickedOrder new item is pushed on the array of content according to its value.

  • start becomes the default value, keeping the current behavior
  • end pushes the item to end of the content array
  • function if user defined a function they may control where to push
    the new item

As mentioned, keeping the default value at start avoids breaking the current behavior.

Closes #125

Alternate Designs

I considered only using a boolean value alone with a prop like pickedOrderEnd, only to negate the current behavior when needed, but the current approach seems more versatile. Also, adding the option for a function allows the user reach for control of how this is done in some specific cases (e.g. always pushing in alphabetical order).

Possible Drawbacks

Given the default behavior is kept, I don't see any at the moment.

Verification Process

I've only done manual testing, but am hoping to open this for feedback, especially for the prop name (propInitialOrder, maybe?).
Will do some unit testing/e2e depending on how #124 is reviewed (they change the same components and it would be nice to reduce conflicts).

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests passed.

Changelog Entry

Credits

Props @xipasduarte

When selecting a new item for the list, the only option was to have the
item pushed to the top. This adds support for two other sorts:
- `end` pushes the item to end of the `content` array
- `function` if user defined a function they may control where to push
  the new item
- `start` becomes the default value, keeping the current behavior
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.

ContentPicker new prop to control selected initial order
2 participants