fix: Initial positioning of mention menu in comments

This commit is contained in:
Tom Moor
2023-04-05 20:06:24 -04:00
parent 99e4b458df
commit 6c16ffb99a
2 changed files with 10 additions and 1 deletions

View File

@@ -36,6 +36,7 @@ type Props = Omit<
>;
function MentionMenu({ search, isActive, ...rest }: Props) {
const [loaded, setLoaded] = React.useState(false);
const [items, setItems] = React.useState<MentionItem[]>([]);
const { t } = useTranslation();
const { users, auth } = useStores();
@@ -75,6 +76,7 @@ function MentionMenu({ search, isActive, ...rest }: Props) {
}));
setItems(items);
setLoaded(true);
}
}, [auth.user?.id, loading, data]);
@@ -91,6 +93,12 @@ function MentionMenu({ search, isActive, ...rest }: Props) {
);
};
// Prevent showing the menu until we have data otherwise it will be positioned
// incorrectly due to the height being unknown.
if (!loaded) {
return null;
}
return (
<SuggestionsMenu
{...rest}