Skip to content

Commit

Permalink
STCOM-1231 Added indexRef and inputRef props to <SearchField> (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
BogdanDenis authored Nov 8, 2023
1 parent 28410c3 commit b584da8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Add support for new match option `containsAll` in `<AdvancedSearch>`. Refs STCOM-1223.
* Ensure CSS visibility of datepicker's year input number spinner. Refs STCOM-1225.
* Include pagination height in MCL container height calculation. Refs STCOM-1224.
* Added `indexRef` and `inputRef` props to `<SearchField>`. Refs STCOM-1231.

## [12.0.0](https://github.com/folio-org/stripes-components/tree/v12.0.0) (2023-10-11)
[Full Changelog](https://github.com/folio-org/stripes-components/compare/v11.0.0...v12.0.0)
Expand Down
13 changes: 12 additions & 1 deletion lib/SearchField/SearchField.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,15 @@ const propTypes = {
disabled: PropTypes.bool,
id: PropTypes.string,
indexName: PropTypes.string,
indexRef: PropTypes.oneOfType([
PropTypes.func,
PropTypes.shape({ current: PropTypes.instanceOf(Element) }),
]),
inputClass: PropTypes.string,
inputRef: PropTypes.object,
inputRef: PropTypes.oneOfType([
PropTypes.func,
PropTypes.shape({ current: PropTypes.instanceOf(Element) }),
]),
inputType: PropTypes.oneOf(Object.values(INPUT_TYPES)),
loading: PropTypes.bool,
lockWidth: PropTypes.bool,
Expand Down Expand Up @@ -87,6 +94,8 @@ const SearchField = (props) => {
onSubmitSearch,
lockWidth,
newLineOnShiftEnter,
inputRef,
indexRef,
...rest
} = props;

Expand All @@ -112,6 +121,7 @@ const SearchField = (props) => {
selectClass={css.select}
value={selectedIndex}
name={indexName}
inputRef={indexRef}
>
{searchableOptions}
</Select>
Expand Down Expand Up @@ -149,6 +159,7 @@ const SearchField = (props) => {
value: value || '',
readOnly: loading || rest.readOnly,
placeholder: inputPlaceholder,
inputRef,
};

const textFieldProps = {
Expand Down
2 changes: 2 additions & 0 deletions lib/SearchField/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ Name | type | Description
placeholder | string | Adds a placeholder to the search input field
id | string | Adds an ID to the input field
className | string | Adds a className to the root element
indexRef | ref | Reference to search index dropdown element.
inputClass | string | Adds a className to the input
inputRef | ref | Reference to search query input element.
inputType | string | Controls if input box should be `input` or `textarea`. Accepted values are `input` and `textarea`.
aria-label | string | Adds an aria label to the input field. Camel-case `ariaLabel` is also accepted.
value | string | The value of the input field
Expand Down

0 comments on commit b584da8

Please sign in to comment.