Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

✨ Disable comments by default for new polls (#2792)

Luke Vella8f52a426ee77
diff --git a/apps/web/src/app/api/private/[...route]/route.ts b/apps/web/src/app/api/private/[...route]/route.ts
index 74ee6f6b1..e0177820e 100644
--- a/apps/web/src/app/api/private/[...route]/route.ts
+++ b/apps/web/src/app/api/private/[...route]/route.ts
@@ -305,7 +305,7 @@ app.post(
requireParticipantEmail: input.requireEmail,
hideParticipants: input.hideParticipants,
hideScores: input.hideScores,
- disableComments: input.disableComments,
+ disableComments: poll.disableComments,
isGuest: false,
},
groups: {
diff --git a/apps/web/src/app/api/private/schemas.ts b/apps/web/src/app/api/private/schemas.ts
index b7ebf6f55..f622d2693 100644
--- a/apps/web/src/app/api/private/schemas.ts
+++ b/apps/web/src/app/api/private/schemas.ts
@@ -106,7 +106,8 @@ export const createPollInputSchema = z
example: false,
}),
disableComments: z.boolean().optional().openapi({
- description: "Disable the comments section",
+ description:
+ "Disable the comments section. Defaults to true: new polls have comments disabled unless this is set to false.",
example: false,
}),
spaceId: z.string().optional().openapi({
diff --git a/apps/web/src/features/poll/components/create-poll.tsx b/apps/web/src/features/poll/components/create-poll.tsx
index b462d753c..a6ccf3a85 100644
--- a/apps/web/src/features/poll/components/create-poll.tsx
+++ b/apps/web/src/features/poll/components/create-poll.tsx
@@ -72,7 +72,7 @@ export const CreatePoll: React.FunctionComponent = () => {
options: [],
hideScores: false,
hideParticipants: false,
- disableComments: false,
+ disableComments: true,
duration: 60,
lockTimeZone: false,
allDay: false,
diff --git a/apps/web/src/features/poll/components/forms/poll-settings.tsx b/apps/web/src/features/poll/components/forms/poll-settings.tsx
index 168917ba9..a890dd5b4 100644
--- a/apps/web/src/features/poll/components/forms/poll-settings.tsx
+++ b/apps/web/src/features/poll/components/forms/poll-settings.tsx
@@ -9,7 +9,7 @@ import {
import { FormField } from "@rallly/ui/form";
import { Switch } from "@rallly/ui/switch";
import { AtSignIcon, EyeIcon, MessageCircleIcon, VoteIcon } from "lucide-react";
-import type React from "react";
+import React from "react";
import { useFormContext } from "react-hook-form";
import { showPayWall, useIsFree } from "@/features/billing/client";
import { ProBadge } from "@/features/billing/components/pro-badge";
@@ -31,6 +31,8 @@ const PollSetting = ({
}) => {
const form = useFormContext<PollSettingsFormData>();
const isFree = useIsFree();
+ const titleId = React.useId();
+ const descriptionId = React.useId();
return (
<FormField
@@ -41,15 +43,23 @@ const PollSetting = ({
<label className="flex cursor-pointer select-none items-start gap-x-3 rounded-xl border bg-card p-3 hover:bg-card-accent">
<Icon className="size-4 shrink-0 translate-y-0.5 text-muted-foreground" />
<div className="grow">
- <div className="flex items-center gap-x-2 font-medium text-sm">
+ <div
+ id={titleId}
+ className="flex items-center gap-x-2 font-medium text-sm"
+ >
{title}
{pro && isFree ? <ProBadge /> : null}
</div>
- <div className="mt-1 text-muted-foreground text-xs">
+ <div
+ id={descriptionId}
+ className="mt-1 text-muted-foreground text-xs"
+ >
{description}
</div>
</div>
<Switch
+ aria-labelledby={titleId}
+ aria-describedby={descriptionId}
checked={!!field.value}
onCheckedChange={(checked) => {
if (checked && pro && isFree) {
@@ -60,6 +70,11 @@ const PollSetting = ({
});
} else {
field.onChange(checked);
+ if (name === "disableComments") {
+ posthog?.capture("poll_settings:comments_toggle_click", {
+ enabled: !checked,
+ });
+ }
}
}}
/>
diff --git a/apps/web/src/features/poll/mutations.ts b/apps/web/src/features/poll/mutations.ts
index 96ab3e96a..81ba18443 100644
--- a/apps/web/src/features/poll/mutations.ts
+++ b/apps/web/src/features/poll/mutations.ts
@@ -63,6 +63,7 @@ export const createPoll = async ({
timeZone: true,
status: true,
createdAt: true,
+ disableComments: true,
user: {
select: {
name: true,
diff --git a/apps/web/tests/new-poll-page.ts b/apps/web/tests/new-poll-page.ts
index 567dd4242..3b160aa2d 100644
--- a/apps/web/tests/new-poll-page.ts
+++ b/apps/web/tests/new-poll-page.ts
@@ -23,7 +23,13 @@ export class NewPollPage {
await this.page.goto("/new");
}
- async create({ name }: { name: string }): Promise<CreatePollSuccessDialog> {
+ async create({
+ name,
+ enableComments,
+ }: {
+ name: string;
+ enableComments?: boolean;
+ }): Promise<CreatePollSuccessDialog> {
const page = this.page;
await page.getByLabel(/title|event/i).fill(name);
@@ -45,6 +51,11 @@ export class NewPollPage {
await page.getByText("10", { exact: true }).first().click();
await page.getByText("15", { exact: true }).first().click();
+ if (enableComments) {
+ // Comments are off by default; turn the "Disable comments" setting off
+ await page.getByRole("switch", { name: /disable comments/i }).click();
+ }
+
await page.getByRole("button", { name: /create poll/i }).click();
const successDialog = new CreatePollSuccessDialog(page);
diff --git a/apps/web/tests/vote-and-comment.spec.ts b/apps/web/tests/vote-and-comment.spec.ts
index 3dc231567..1fd5a3512 100644
--- a/apps/web/tests/vote-and-comment.spec.ts
+++ b/apps/web/tests/vote-and-comment.spec.ts
@@ -16,7 +16,10 @@ test.describe(() => {
const newPollPage = new NewPollPage(page);
await newPollPage.goto();
- const dialog = await newPollPage.create({ name: "Monthly Meetup" });
+ const dialog = await newPollPage.create({
+ name: "Monthly Meetup",
+ enableComments: true,
+ });
pollPage = await dialog.goToPollPage();
// Extract the poll ID from the URL
diff --git a/packages/database/prisma/migrations/20260730120000_default_disable_comments_to_true/migration.sql b/packages/database/prisma/migrations/20260730120000_default_disable_comments_to_true/migration.sql
new file mode 100644
index 000000000..e99736451
--- /dev/null
+++ b/packages/database/prisma/migrations/20260730120000_default_disable_comments_to_true/migration.sql
@@ -0,0 +1,2 @@
+-- AlterTable
+ALTER TABLE "polls" ALTER COLUMN "disable_comments" SET DEFAULT true;
diff --git a/packages/database/prisma/models/poll.prisma b/packages/database/prisma/models/poll.prisma
index 894cefcc5..ba3ecd3e9 100644
--- a/packages/database/prisma/models/poll.prisma
+++ b/packages/database/prisma/models/poll.prisma
@@ -48,7 +48,7 @@ model Poll {
scheduledEventId String? @map("scheduled_event_id")
hideParticipants Boolean @default(false) @map("hide_participants")
hideScores Boolean @default(false) @map("hide_scores")
- disableComments Boolean @default(false) @map("disable_comments")
+ disableComments Boolean @default(true) @map("disable_comments")
requireParticipantEmail Boolean @default(false) @map("require_participant_email")
muted Boolean @default(false)
diff --git a/packages/database/prisma/seed.ts b/packages/database/prisma/seed.ts
index 448afee3c..444264abb 100644
--- a/packages/database/prisma/seed.ts
+++ b/packages/database/prisma/seed.ts
@@ -115,7 +115,8 @@ async function main() {
scheduledEventId: poll.scheduledEventId,
hideParticipants: poll.hideParticipants,
hideScores: poll.hideScores,
- disableComments: poll.disableComments,
+ // Seed polls model pre-existing data, which predates the comments-off default
+ disableComments: poll.disableComments ?? false,
requireParticipantEmail: poll.requireParticipantEmail,
kind,
},