diff --git a/.gitignore b/.gitignore index e7b35c505c..bf87a7e4f4 100644 --- a/.gitignore +++ b/.gitignore @@ -47,4 +47,7 @@ webapp.xml .idea/ # Figma MCP -figma-images/ \ No newline at end of file +figma-images/ + +# Node compile cache +node-compile-cache/ \ No newline at end of file diff --git a/packages/shared/src/components/post/PostEngagements.tsx b/packages/shared/src/components/post/PostEngagements.tsx index 444b6aeccf..d648244075 100644 --- a/packages/shared/src/components/post/PostEngagements.tsx +++ b/packages/shared/src/components/post/PostEngagements.tsx @@ -22,7 +22,7 @@ import { import usePersistentContext from '../../hooks/usePersistentContext'; import { PostContentShare } from './common/PostContentShare'; import { SourceType } from '../../graphql/sources'; -import { useActions } from '../../hooks'; +import { useActions, useViewSize, ViewSize } from '../../hooks'; import { ActionType } from '../../graphql/actions'; import { AdAsComment } from '../comments/AdAsComment'; import { Typography, TypographyType } from '../typography/Typography'; @@ -63,7 +63,9 @@ function PostEngagements({ useSettingsContext(); const { user, showLogin } = useAuthContext(); const { isPlus } = usePlusSubscription(); + const isMobile = !useViewSize(ViewSize.Tablet); const commentRef = useRef(); + const commentsContainerRef = useRef(null); const [authorOnboarding, setAuthorOnboarding] = useState(false); const [permissionNotificationCommentId, setPermissionNotificationCommentId] = useState(); @@ -100,6 +102,17 @@ function PostEngagements({ if (post.source?.type === SourceType.Squad) { completeAction(ActionType.SquadFirstComment); } + + // On mobile, scroll to show the newly added comment + if (isMobile && commentsContainerRef.current) { + // Use setTimeout to ensure the comment is rendered before scrolling + setTimeout(() => { + commentsContainerRef.current?.scrollIntoView({ + behavior: 'smooth', + block: 'start', + }); + }, 100); + } }; useEffect(() => { @@ -160,16 +173,18 @@ function PostEngagements({ CommentInputOrModal={CommentInputOrModal} /> {!isPlus && } - openShareComment(comment, post)} - onClickUpvote={(id, count) => onShowUpvoted(id, count, 'comment')} - permissionNotificationCommentId={permissionNotificationCommentId} - joinNotificationCommentId={joinNotificationCommentId} - onCommented={onCommented} - /> +
+ openShareComment(comment, post)} + onClickUpvote={(id, count) => onShowUpvoted(id, count, 'comment')} + permissionNotificationCommentId={permissionNotificationCommentId} + joinNotificationCommentId={joinNotificationCommentId} + onCommented={onCommented} + /> +
{authorOnboarding && (