chore: UI commenting keyboard help

This commit is contained in:
Danish Arora 2025-09-15 15:00:07 +05:30
parent 8cc956682c
commit af59b9000a
No known key found for this signature in database
GPG Key ID: 1C6EF37CDAE1426E
2 changed files with 14 additions and 2 deletions

View File

@ -105,7 +105,9 @@ const PostDetail = () => {
// Handle keyboard shortcuts
const handleKeyDown = (e: React.KeyboardEvent) => {
if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') {
// Enter inserts newline by default. Send on Ctrl+Enter or Shift+Enter.
const isSendCombo = (e.ctrlKey || e.metaKey || e.shiftKey) && e.key === 'Enter';
if (isSendCombo) {
e.preventDefault();
if (!isCreatingComment && newComment.trim()) {
handleCreateComment(e as React.FormEvent);
@ -287,6 +289,10 @@ const PostDetail = () => {
initialHeight={140}
maxHeight={600}
/>
<div className="flex items-center justify-between text-xs text-muted-foreground mt-1 mb-2">
<span>Press Enter for newline Ctrl+Enter or Shift+Enter to send</span>
<span />
</div>
<div className="flex justify-end">
<Button
type="submit"

View File

@ -126,7 +126,9 @@ const PostList = () => {
// Handle keyboard shortcuts
const handleKeyDown = (e: React.KeyboardEvent) => {
if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') {
// Enter inserts newline by default. Send on Ctrl+Enter or Shift+Enter.
const isSendCombo = (e.ctrlKey || e.metaKey || e.shiftKey) && e.key === 'Enter';
if (isSendCombo) {
e.preventDefault();
if (!isCreatingPost && newPostContent.trim() && newPostTitle.trim()) {
handleCreatePost(e as React.FormEvent);
@ -229,6 +231,10 @@ const PostList = () => {
disabled={isCreatingPost}
/>
</div>
<div className="flex items-center justify-between text-xs text-muted-foreground mt-1 mb-2">
<span>Press Enter for newline Ctrl+Enter or Shift+Enter to post</span>
<span />
</div>
<div className="flex justify-end">
<Button
type="submit"