Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32525183
D6049.1767139146.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D6049.1767139146.diff
View Options
diff --git a/web/chat/typeahead-tooltip.react.js b/web/chat/typeahead-tooltip.react.js
--- a/web/chat/typeahead-tooltip.react.js
+++ b/web/chat/typeahead-tooltip.react.js
@@ -5,10 +5,10 @@
import type { RelativeMemberInfo } from 'lib/types/thread-types';
-import Button from '../components/button.react';
import type { InputState } from '../input/input-state';
import {
getTypeaheadTooltipActions,
+ getTypeaheadTooltipButtons,
getTypeaheadTooltipPosition,
} from '../utils/typeahead-utils';
import type { TypeaheadMatchedStrings } from './chat-input-bar.react';
@@ -70,13 +70,10 @@
[tooltipPosition],
);
- const tooltipButtons = React.useMemo(() => {
- return actions.map(({ key, onClick, actionButtonContent }) => (
- <Button key={key} onClick={onClick} className={css.suggestion}>
- <span>@{actionButtonContent}</span>
- </Button>
- ));
- }, [actions]);
+ const tooltipButtons = React.useMemo(
+ () => getTypeaheadTooltipButtons(actions),
+ [actions],
+ );
if (!actions || actions.length === 0) {
return null;
diff --git a/web/utils/typeahead-utils.js b/web/utils/typeahead-utils.js
--- a/web/utils/typeahead-utils.js
+++ b/web/utils/typeahead-utils.js
@@ -7,6 +7,8 @@
import type { RelativeMemberInfo } from 'lib/types/thread-types';
import { typeaheadStyle } from '../chat/chat-constants';
+import css from '../chat/typeahead-tooltip.css';
+import Button from '../components/button.react';
const webTypeaheadRegex: RegExp = new RegExp(
`(?<textPrefix>(?:^(?:.|\n)*\\s+)|^)@(?<username>${oldValidUsernameRegexString})?$`,
@@ -119,6 +121,16 @@
actionButtonContent: stringForUserExplicit(suggestedUser),
}));
}
+
+function getTypeaheadTooltipButtons(
+ actions: $ReadOnlyArray<TypeaheadTooltipAction>,
+): $ReadOnlyArray<React.Node> {
+ return actions.map(({ key, onClick, actionButtonContent }) => (
+ <Button key={key} onClick={onClick} className={css.suggestion}>
+ <span>@{actionButtonContent}</span>
+ </Button>
+ ));
+}
function getTypeaheadTooltipPosition(
textarea: HTMLTextAreaElement,
actionsLength: number,
@@ -153,5 +165,6 @@
webTypeaheadRegex,
getCaretOffsets,
getTypeaheadTooltipActions,
+ getTypeaheadTooltipButtons,
getTypeaheadTooltipPosition,
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 30, 11:59 PM (11 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5870872
Default Alt Text
D6049.1767139146.diff (2 KB)
Attached To
Mode
D6049: [web] Keyboard support for typeahead [9/13] - Refactor getTypeaheadTooltipButtons as a function
Attached
Detach File
Event Timeline
Log In to Comment