mirror of
https://github.com/fergalmoran/turnstone.git
synced 2025-12-22 09:49:56 +00:00
Add note to README regarding onSelect being called when an item is no longer selected
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
### 1.1.2 (15 Mar 2022)
|
||||
|
||||
- Add note to README regarding onSelect being called when an item is no longer selected
|
||||
- Use autofocus HTML attribute instead of a useEffect hook
|
||||
- Add MIT License
|
||||
- Add precommit hooks for test and lint
|
||||
|
||||
@@ -424,6 +424,7 @@ in order to exit the focused state of the search box.
|
||||
- The following arguments are passed to the `onSelect` function:
|
||||
1. `selectedItem` The item selected by the user. This is in the same format as received from `listbox.data`.
|
||||
1. `displayField` (string / number / undefined) The field in `selectedItem` that contains the text displayed in the listbox. If `selectedItem` is not an array or an object, `displayField` is `undefined`.
|
||||
- This function is also called with `undefined` arguments to indicate when an item is no longer selected
|
||||
|
||||
#### `onTab`
|
||||
- Type: `function`
|
||||
|
||||
@@ -71,7 +71,6 @@ export const useSelected = (selected, queryInput, typeaheadInput, onSelect) => {
|
||||
displayField = selected.displayField
|
||||
}
|
||||
|
||||
//TODO: Check if it's necessary to call this when value is undef
|
||||
if (typeof onSelect === 'function') onSelect(value, displayField)
|
||||
}, [selected, onSelect, queryInput, typeaheadInput])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user