Skip to content

Commit

Permalink
RemoteSelect: pass searchQueryParamName as a property
Browse files Browse the repository at this point in the history
  • Loading branch information
carlinmack authored and slint committed Jun 28, 2024
1 parent 64c5ce9 commit 8afbdcc
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 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,
searchQueryParamName,
} = this.props;

try {
const response = await axios.get(suggestionAPIUrl, {
params: {
suggest: searchQuery,
[searchQueryParamName]: searchQuery,
size: DEFAULT_SUGGESTION_SIZE,
...suggestionAPIQueryParams,
},
Expand Down Expand Up @@ -172,6 +176,7 @@ export class RemoteSelectField extends Component {
serializeAddedValue,
suggestionAPIHeaders,
debounceTime,
searchQueryParamName,
noResultsMessage,
loadingMessage,
suggestionsErrorMessage,
Expand All @@ -191,6 +196,7 @@ export class RemoteSelectField extends Component {
serializeSuggestions,
serializeAddedValue,
debounceTime,
searchQueryParamName,
noResultsMessage,
loadingMessage,
suggestionsErrorMessage,
Expand Down Expand Up @@ -270,6 +276,7 @@ RemoteSelectField.propTypes = {
loadingMessage: PropTypes.string,
suggestionsErrorMessage: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
noQueryMessage: PropTypes.string,
searchQueryParamName: PropTypes.string,
preSearchChange: PropTypes.func, // Takes a string and returns a string
onValueChange: PropTypes.func, // Takes the SUI hanf and updated selectedSuggestions
search: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
Expand All @@ -282,6 +289,7 @@ RemoteSelectField.defaultProps = {
suggestionAPIQueryParams: {},
suggestionAPIHeaders: {},
serializeSuggestions: serializeSuggestions,
searchQueryParamName: "suggest",
suggestionsErrorMessage: "Something went wrong...",
noQueryMessage: "Search...",
noResultsMessage: "No results found.",
Expand Down

0 comments on commit 8afbdcc

Please sign in to comment.