Skip to content

Commit

Permalink
fix(select-input): incorrect Downshift key (#369)
Browse files Browse the repository at this point in the history
* fix(select-input): incorrect Downshift key

* chore: changeset
  • Loading branch information
thiskevinwang committed Sep 30, 2021
1 parent 9583d91 commit 53b22e1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/three-bags-hear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hashicorp/react-select-input': patch
---

This fixes a bug where an object was being passed to Downshift's key
6 changes: 4 additions & 2 deletions packages/select-input/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import s from './style.module.css'
* @prop {String} name - input name attribute
* @prop {String} label - text to display above the input
* @prop {String} defaultLabel - text to act as placeholder label
* @prop {String} value - set the value via prop
* @prop {Object} value - set the value via prop
* @prop {String} value.name - item name
* @prop {String} value.label - item label
* @prop {Array} options - array of option objects within the select
* @prop {String} options[].name - option name
* @prop {String} options[].label - option label
Expand All @@ -28,7 +30,7 @@ export default function SelectInput({
// Changes to the value prop will re-render this component by updating the key value.
return (
<Downshift
key={value}
key={value.name}
initialSelectedItem={value}
itemToString={(item) => item && item.name}
onChange={(item) => {
Expand Down
2 changes: 2 additions & 0 deletions packages/select-input/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ test.todo('displays an alternate placeholder if `defaultLabel` is specified')
test.todo('displays a custom label if `label` is specified')
test.todo('uses the `name` if specified for the input')
test.todo('sets the `value` is one is provided via prop')

test.todo('displays correct value when the value is programmatically updated')

1 comment on commit 53b22e1

@vercel
Copy link

@vercel vercel bot commented on 53b22e1 Sep 30, 2021

Choose a reason for hiding this comment

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

Please sign in to comment.