Skip to content

Commit

Permalink
Do not fetch user data on suggestions popup click in Comments Section
Browse files Browse the repository at this point in the history
- Fixes hotosm#6166
  • Loading branch information
royallsilwallz committed Mar 6, 2024
1 parent 7307769 commit 2e781a5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions frontend/src/components/comments/commentInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ export const CommentInputField = ({
values: async (query, cb) => {
try {
if (!query) return cb(contributors.map((username) => ({ username })));

// do not fetch data if the value comes from suggestions popup click
const isValueFromSuggestion = /^\[.*?\]\s$/.test(query);
if (isValueFromSuggestion) return;

const res = await fetchLocalJSONAPI(`users/queries/filter/${query}/`, token);
cb(res.usernames.map((username) => ({ username })));
} catch (e) {
Expand Down

0 comments on commit 2e781a5

Please sign in to comment.