From ba99cbaf2af7f2f153f1a8e33fb7b991efe3a3fb Mon Sep 17 00:00:00 2001 From: Leda <38331868+LedaThemis@users.noreply.github.com> Date: Tue, 14 Jun 2022 14:24:13 +0000 Subject: [PATCH] fix: bug in user/channel mention when query text is empty (#659) --- src/components/common/AutoComplete.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/common/AutoComplete.tsx b/src/components/common/AutoComplete.tsx index 3d038537..2b7d5196 100644 --- a/src/components/common/AutoComplete.tsx +++ b/src/components/common/AutoComplete.tsx @@ -88,7 +88,7 @@ export function useAutoComplete( ? "emoji" : "user", search.toLowerCase(), - j + 1, + current === ":" ? j + 1 : j, ]; } } @@ -242,7 +242,7 @@ export function useAutoComplete( ); } else if (state.type === "user") { content.splice( - index - 1, + index, search.length + 1, "<@", state.matches[state.selected]._id, @@ -250,7 +250,7 @@ export function useAutoComplete( ); } else { content.splice( - index - 1, + index, search.length + 1, "<#", state.matches[state.selected]._id,