Skip to content

Commit

Permalink
Disable invalid space error on url on carriage returns (#1464)
Browse files Browse the repository at this point in the history
* run query on Enter
  • Loading branch information
Onokaev authored Feb 22, 2022
1 parent 87c2228 commit b99d239
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class AutoComplete extends Component<IAutoCompleteProps, IAutoCompleteState> {
const selected = filteredSuggestions[activeSuggestion];
this.appendSuggestionToUrl(selected);
} else {
event.preventDefault();
this.props.contentChanged(queryUrl);
this.props.runQuery();
}
Expand Down Expand Up @@ -250,7 +251,7 @@ class AutoComplete extends Component<IAutoCompleteProps, IAutoCompleteState> {
}

private setSuggestions(suggestions: string[], compare?: string) {
const sortedSuggestions = suggestions.sort(dynamicSort(null, SortOrder.ASC));
const sortedSuggestions = this.sortSuggestions(suggestions);
this.setState({
filteredSuggestions: sortedSuggestions,
suggestions: sortedSuggestions,
Expand All @@ -259,6 +260,10 @@ class AutoComplete extends Component<IAutoCompleteProps, IAutoCompleteState> {
});
}

private sortSuggestions(suggestions: string[]): string[]{
return suggestions.sort(dynamicSort(null, SortOrder.ASC));
}

public componentDidUpdate = (prevProps: IAutoCompleteProps) => {
if (prevProps.autoCompleteOptions !== this.props.autoCompleteOptions) {
if (this.props.autoCompleteOptions) {
Expand Down
3 changes: 2 additions & 1 deletion src/tests/utils/sample-url-generation.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ describe('hasWhiteSpaces should', () => {
{url: 'https://graph.microsoft.com/v1.0/ me', output: true},
{url:
'https://graph.microsoft.com/v1.0/me/contacts?$filter=emailAddresses/any(a:a/address eq \'garth@contoso.com\')',
output: false}
output: false},
{url: 'https://graph.microsoft.com/v1.0/me ', output: true}
];
invalidUrls.forEach(invalidUrl => {
it(`validate whitespaces in the url: ${invalidUrl.url}`, () => {
Expand Down

0 comments on commit b99d239

Please sign in to comment.