From 1b7fd31b88b9c2c3a76831ce1187f392ad24eb3c Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Thu, 15 Sep 2022 17:12:49 -0700 Subject: [PATCH] Fix '%' mentioning if you escape out --- .../editor/contract-mention-suggestion.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/web/components/editor/contract-mention-suggestion.ts b/web/components/editor/contract-mention-suggestion.ts index 79525cfc..65b4ff62 100644 --- a/web/components/editor/contract-mention-suggestion.ts +++ b/web/components/editor/contract-mention-suggestion.ts @@ -61,10 +61,16 @@ export const contractMentionSuggestion: Suggestion = { }) }, onKeyDown(props) { - if (props.event.key === 'Escape') { - popup?.[0].hide() - return true - } + if (props.event.key) + if ( + props.event.key === 'Escape' || + // Also break out of the mention if the tooltip isn't visible + (props.event.key === 'Enter' && !popup?.[0].state.isShown) + ) { + popup?.[0].destroy() + component?.destroy() + return false + } return (component?.ref as any)?.onKeyDown(props) }, onExit() {