mirror of
https://github.com/logos-messaging/OpChan.git
synced 2026-01-02 12:53:10 +00:00
chore: allow cmd+enter to post
This commit is contained in:
parent
244119bb05
commit
9b1a6ea548
@ -96,6 +96,16 @@ export function CreateCellDialog({
|
||||
}
|
||||
};
|
||||
|
||||
// Handle keyboard shortcuts
|
||||
const handleKeyDown = (e: React.KeyboardEvent) => {
|
||||
if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
if (!isCreatingCell && canCreateCell) {
|
||||
form.handleSubmit(onSubmit)();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<DialogTrigger asChild>
|
||||
@ -108,7 +118,7 @@ export function CreateCellDialog({
|
||||
<DialogTitle className="text-glow">Create New Cell</DialogTitle>
|
||||
</DialogHeader>
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
|
||||
<form onSubmit={form.handleSubmit(onSubmit)} onKeyDown={handleKeyDown} className="space-y-4">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="title"
|
||||
|
||||
@ -101,6 +101,16 @@ const PostDetail = () => {
|
||||
}
|
||||
};
|
||||
|
||||
// Handle keyboard shortcuts
|
||||
const handleKeyDown = (e: React.KeyboardEvent) => {
|
||||
if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
if (!isCreatingComment && newComment.trim()) {
|
||||
handleCreateComment(e as React.FormEvent);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const handleVotePost = async (isUpvote: boolean) => {
|
||||
// ✅ Permission checking handled in hook
|
||||
await votePost(post.id, isUpvote);
|
||||
@ -255,7 +265,7 @@ const PostDetail = () => {
|
||||
{/* Comment Form */}
|
||||
{canComment && (
|
||||
<div className="mb-8">
|
||||
<form onSubmit={handleCreateComment}>
|
||||
<form onSubmit={handleCreateComment} onKeyDown={handleKeyDown}>
|
||||
<h2 className="text-sm font-bold mb-2 flex items-center gap-1">
|
||||
<MessageCircle className="w-4 h-4" />
|
||||
Add a comment
|
||||
|
||||
@ -124,6 +124,16 @@ const PostList = () => {
|
||||
}
|
||||
};
|
||||
|
||||
// Handle keyboard shortcuts
|
||||
const handleKeyDown = (e: React.KeyboardEvent) => {
|
||||
if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
if (!isCreatingPost && newPostContent.trim() && newPostTitle.trim()) {
|
||||
handleCreatePost(e as React.FormEvent);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const handleVotePost = async (postId: string, isUpvote: boolean) => {
|
||||
// ✅ Permission checking handled in hook
|
||||
await votePost(postId, isUpvote);
|
||||
@ -198,7 +208,7 @@ const PostList = () => {
|
||||
|
||||
{canPost && (
|
||||
<div className="section-spacing">
|
||||
<form onSubmit={handleCreatePost}>
|
||||
<form onSubmit={handleCreatePost} onKeyDown={handleKeyDown}>
|
||||
<h2 className="text-sm font-bold mb-2 flex items-center gap-1">
|
||||
<MessageSquare className="w-4 h-4" />
|
||||
New Thread
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user