Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QA: 모바일 기기에서만 suggestionAboveCursor #807

Merged
merged 1 commit into from
Jul 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/components/feed/Mention/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useQueryGetMentionUsers } from '@api/user/hooks';
import { colors } from '@sopt-makers/colors';
import { fontsObject } from '@sopt-makers/fonts';
import { keyframes, styled } from '@stitches/react';
import React, { useCallback } from 'react';
import React, { useCallback, useEffect, useState } from 'react';
import { MentionsInput, Mention, SuggestionDataItem } from 'react-mentions';
import DefaultProfile from 'public/assets/svg/mention_profile_default.svg';
import { parseMentionedUserIds } from '@components/util/parseMentionedUserIds';
Expand Down Expand Up @@ -35,6 +35,15 @@ const CommonMention = ({
setUserIds,
isComment,
}: CommonMentionProps) => {
const [isMobile, setIsMobile] = useState(false);

useEffect(() => {
const userAgent = navigator.userAgent;
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent)) {
setIsMobile(true);
}
}, []);

const { data: mentionUserList } = useQueryGetMentionUsers();

const filterUsersBySearchTerm = (searchTerm: string, users: mentionableDataType[]) => {
Expand Down Expand Up @@ -101,6 +110,7 @@ const CommonMention = ({
onFocus={() => setIsFocused(true)}
customSuggestionsContainer={customSuggestionsContainer}
style={isComment ? CommentMentionStyle : FeedModalMentionStyle}
forceSuggestionsAboveCursor={isMobile}
>
<Mention
trigger="@"
Expand Down
Loading