Skip to content

Commit 4faa9e0

Browse files
committed
scroll to bottom of replies
1 parent e0eb21f commit 4faa9e0

File tree

1 file changed

+12
-2
lines changed
  • packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Dialog

1 file changed

+12
-2
lines changed

packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Dialog/index.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,16 @@ export const Dialog: React.FC = () => {
144144
/>
145145
) : null}
146146
</Stack>
147-
<AddReply comment={comment} />
147+
<AddReply
148+
comment={comment}
149+
onSubmit={() => {
150+
// scroll to bottom of the list,
151+
// have to wait for it to load though :)
152+
window.requestAnimationFrame(() => {
153+
listRef.current.scrollTop = listRef.current.scrollHeight;
154+
});
155+
}}
156+
/>
148157
</>
149158
)}
150159
</Stack>
@@ -388,7 +397,7 @@ const Replies = ({ replies, repliesRenderedCallback }) => {
388397
);
389398
};
390399

391-
const AddReply = ({ comment }) => {
400+
const AddReply = ({ comment, ...props }) => {
392401
const { actions } = useOvermind();
393402
const [value, setValue] = useState('');
394403

@@ -398,6 +407,7 @@ const AddReply = ({ comment }) => {
398407
content: value,
399408
parentCommentId: comment.id,
400409
});
410+
if (props.onSubmit) props.onSubmit();
401411
};
402412

403413
return (

0 commit comments

Comments
 (0)