Skip to content

Commit bed1221

Browse files
committed
fix #7726 -- improve @mention popup in case when there are no results (unconfused Andrey); properly center ai submenu label
1 parent 31393be commit bed1221

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

src/packages/frontend/editors/markdown-input/complete.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ rewrote this to use the Antd dropdown, which is more dynamic.
1313
import type { MenuProps } from "antd";
1414
import { Dropdown } from "antd";
1515
import { ReactNode, useCallback, useEffect, useRef, useState } from "react";
16-
1716
import { CSS, ReactDOM } from "@cocalc/frontend/app-framework";
18-
import { MenuItems } from "@cocalc/frontend/components";
17+
import type { MenuItems } from "@cocalc/frontend/components";
1918
import AIAvatar from "@cocalc/frontend/components/ai-avatar";
2019
import { strictMod } from "@cocalc/util/misc";
2120
import { COLORS } from "@cocalc/util/theme";
@@ -48,9 +47,13 @@ type Props = Props1 | Props2;
4847
// WARNING: Complete closing when clicking outside the complete box
4948
// is handled in cell-list on_click. This is ugly code (since not localized),
5049
// but seems to work well for now. Could move.
51-
export function Complete(props: Props) {
52-
const { items, onSelect, onCancel, offset, position } = props;
53-
50+
export function Complete({
51+
items,
52+
onSelect,
53+
onCancel,
54+
offset,
55+
position,
56+
}: Props) {
5457
const items_user = items.filter((item) => !(item.is_llm ?? false));
5558

5659
// All other LLMs that should not show up in the main menu
@@ -174,8 +177,6 @@ export function Complete(props: Props) {
174177
};
175178
}, [onKeyDown, onCancel]);
176179

177-
if (items.length === 0) return null;
178-
179180
selected_key_ref.current = (() => {
180181
if (llm || onlyLLMs) {
181182
const len: number = items_llm.length ?? 1;
@@ -213,9 +214,10 @@ export function Complete(props: Props) {
213214
menuItems.push({
214215
key: "sub_llm",
215216
label: (
216-
<span style={style}>
217-
<AIAvatar size={22} /> More AI Language Models
218-
</span>
217+
<div style={{ ...style, display: "flex", alignItems: "center" }}>
218+
<AIAvatar size={22} />{" "}
219+
<span style={{ marginLeft: "5px" }}>More AI Language Models</span>
220+
</div>
219221
),
220222
style,
221223
children: items_llm.map(({ label, value }) => {
@@ -228,6 +230,10 @@ export function Complete(props: Props) {
228230
});
229231
}
230232

233+
if (menuItems.length == 0) {
234+
menuItems.push({ key: "nothing", label: "No items found", disabled: true });
235+
}
236+
231237
// NOTE: the AI LLM sub-menu is either opened by hovering (clicking closes immediately) or by right-arrow key
232238
const menu: MenuProps = {
233239
selectedKeys: [selected_key_ref.current],

src/packages/frontend/editors/markdown-input/mentionable-users.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import { Tooltip } from "antd";
77
import { List } from "immutable";
88
import { isEmpty } from "lodash";
9-
109
import { Avatar } from "@cocalc/frontend/account/avatar/avatar";
1110
import { useLanguageModelSetting } from "@cocalc/frontend/account/useLanguageModelSetting";
1211
import { redux, useMemo, useTypedRedux } from "@cocalc/frontend/app-framework";

0 commit comments

Comments
 (0)