Skip to content

Commit

Permalink
search: allowing search param key to be modified
Browse files Browse the repository at this point in the history
  • Loading branch information
0einstein0 committed Jun 25, 2024
1 parent 64c5ce9 commit f330002
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/lib/forms/RemoteSelectField.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down Expand Up @@ -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([
Expand All @@ -281,6 +286,7 @@ RemoteSelectField.defaultProps = {
debounceTime: 500,
suggestionAPIQueryParams: {},
suggestionAPIHeaders: {},
searchParamKey: "suggest",
serializeSuggestions: serializeSuggestions,
suggestionsErrorMessage: "Something went wrong...",
noQueryMessage: "Search...",
Expand Down

0 comments on commit f330002

Please sign in to comment.