diff --git a/web/chat/chat-input-bar.react.js b/web/chat/chat-input-bar.react.js --- a/web/chat/chat-input-bar.react.js +++ b/web/chat/chat-input-bar.react.js @@ -52,8 +52,8 @@ import { nonThreadCalendarQuery } from '../selectors/nav-selectors'; import SWMansionIcon from '../SWMansionIcon.react'; import css from './chat-input-bar.css'; -import MentionSuggestionTooltip from './mention-suggestion-tooltip.react'; -import { mentionRegex } from './mention-utils'; +import TypeaheadTooltip from './typeahead-tooltip.react'; +import { typeaheadRegex } from './typeahead-utils'; type BaseProps = { +threadInfo: ThreadInfo, +inputState: InputState, @@ -331,7 +331,7 @@ let typeaheadTooltip; if (this.props.typeaheadMatchedStrings && this.textarea) { typeaheadTooltip = ( - inputSliceEndingAtCursor.length === props.inputState.draft.length || /\s/.test(props.inputState.draft[props.inputState.textCursorPosition]) - ? inputSliceEndingAtCursor.match(mentionRegex) + ? inputSliceEndingAtCursor.match(typeaheadRegex) : null, [ inputSliceEndingAtCursor, diff --git a/web/chat/mention-suggestion-tooltip.css b/web/chat/typeahead-tooltip.css rename from web/chat/mention-suggestion-tooltip.css rename to web/chat/typeahead-tooltip.css diff --git a/web/chat/mention-suggestion-tooltip.react.js b/web/chat/typeahead-tooltip.react.js rename from web/chat/mention-suggestion-tooltip.react.js rename to web/chat/typeahead-tooltip.react.js --- a/web/chat/mention-suggestion-tooltip.react.js +++ b/web/chat/typeahead-tooltip.react.js @@ -10,14 +10,14 @@ import Button from '../components/button.react'; import type { InputState } from '../input/input-state'; import { type TypeaheadMatchedStrings } from './chat-input-bar.react'; -import css from './mention-suggestion-tooltip.css'; +import css from './typeahead-tooltip.css'; import { getTypeaheadTooltipActions, getTypeaheadTooltipPosition, getTypeaheadUserSuggestions, -} from './mention-utils'; +} from './typeahead-utils'; -export type MentionSuggestionTooltipProps = { +export type TypeaheadTooltipProps = { +inputState: InputState, +textarea: HTMLTextAreaElement, +userSearchIndex: SearchIndex, @@ -26,9 +26,7 @@ +matchedStrings: TypeaheadMatchedStrings, }; -function MentionSuggestionTooltip( - props: MentionSuggestionTooltipProps, -): React.Node { +function TypeaheadTooltip(props: TypeaheadTooltipProps): React.Node { const { inputState, textarea, @@ -123,4 +121,4 @@ ); } -export default MentionSuggestionTooltip; +export default TypeaheadTooltip; diff --git a/web/chat/mention-utils.js b/web/chat/typeahead-utils.js rename from web/chat/mention-utils.js rename to web/chat/typeahead-utils.js --- a/web/chat/mention-utils.js +++ b/web/chat/typeahead-utils.js @@ -7,14 +7,14 @@ import { stringForUserExplicit } from 'lib/shared/user-utils'; import type { RelativeMemberInfo } from 'lib/types/thread-types'; -const mentionRegex: RegExp = new RegExp( +const typeaheadRegex: RegExp = new RegExp( `(?(?:^(?:.|\n)*\\s+)|^)@(?${oldValidUsernameRegexString})?$`, ); import { type InputState } from '../input/input-state'; import { typeaheadStyle } from './chat-constants'; -export type MentionSuggestionTooltipAction = { +export type TypeaheadTooltipAction = { +key: string, +onClick: (SyntheticEvent) => mixed, +actionButtonContent: React.Node, @@ -93,7 +93,7 @@ suggestedUsers: $ReadOnlyArray, matchedTextBefore: string, matchedText: string, -): $ReadOnlyArray { +): $ReadOnlyArray { return suggestedUsers .filter( suggestedUser => stringForUserExplicit(suggestedUser) !== 'anonymous', @@ -151,7 +151,7 @@ } export { - mentionRegex, + typeaheadRegex, getTypeaheadUserSuggestions, getCaretOffsets, getTypeaheadTooltipActions,