From f330002b4fabb048857a6c67961e9834d9c934ce Mon Sep 17 00:00:00 2001 From: 0einstein0 Date: Tue, 25 Jun 2024 14:04:16 +0200 Subject: [PATCH] search: allowing search param key to be modified --- src/lib/forms/RemoteSelectField.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/lib/forms/RemoteSelectField.js b/src/lib/forms/RemoteSelectField.js index edae93b3..f3a5267f 100644 --- a/src/lib/forms/RemoteSelectField.js +++ b/src/lib/forms/RemoteSelectField.js @@ -103,13 +103,17 @@ export class RemoteSelectField extends Component { }, this.props.debounceTime); fetchSuggestions = async (searchQuery) => { - const { suggestionAPIUrl, suggestionAPIQueryParams, suggestionAPIHeaders } = - this.props; + const { + suggestionAPIUrl, + suggestionAPIQueryParams, + suggestionAPIHeaders, + searchParamKey, + } = this.props; try { const response = await axios.get(suggestionAPIUrl, { params: { - suggest: searchQuery, + [searchParamKey]: searchQuery, size: DEFAULT_SUGGESTION_SIZE, ...suggestionAPIQueryParams, }, @@ -259,6 +263,7 @@ RemoteSelectField.propTypes = { suggestionAPIUrl: PropTypes.string.isRequired, suggestionAPIQueryParams: PropTypes.object, suggestionAPIHeaders: PropTypes.object, + searchParamKey: PropTypes.string, serializeSuggestions: PropTypes.func, serializeAddedValue: PropTypes.func, initialSuggestions: PropTypes.oneOfType([ @@ -281,6 +286,7 @@ RemoteSelectField.defaultProps = { debounceTime: 500, suggestionAPIQueryParams: {}, suggestionAPIHeaders: {}, + searchParamKey: "suggest", serializeSuggestions: serializeSuggestions, suggestionsErrorMessage: "Something went wrong...", noQueryMessage: "Search...",