Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(calendar): use Checkbox.Label instead of a label root (#6107)

gbirmand3aba436d69f
diff --git a/apps/web/src/features/calendar/components/CalendarSettingsDropdown.tsx b/apps/web/src/features/calendar/components/CalendarSettingsDropdown.tsx
index 5c164db4ea..25eb434eef 100644
--- a/apps/web/src/features/calendar/components/CalendarSettingsDropdown.tsx
+++ b/apps/web/src/features/calendar/components/CalendarSettingsDropdown.tsx
@@ -297,19 +297,20 @@ function MobileCalendarSettings(props: { controls: CalendarSettingsControls }) {
<For each={calendarView.sources()}>
{(source) => (
<Checkbox
- as="label"
checked={calendarView.isSourceVisible(source.id)}
onChange={(checked) =>
controls.changeSourceVisibility(source.id, checked)
}
class={DRAWER_ROW_CLASS}
>
- <span
- aria-hidden="true"
- class="size-2.5 shrink-0 rounded-sm"
- style={{ 'background-color': source.color }}
- />
- <span class="min-w-0 flex-1 truncate">{source.name}</span>
+ <Checkbox.Label class="flex min-w-0 flex-1 items-center gap-2">
+ <span
+ aria-hidden="true"
+ class="size-2.5 shrink-0 rounded-sm"
+ style={{ 'background-color': source.color }}
+ />
+ <span class="min-w-0 flex-1 truncate">{source.name}</span>
+ </Checkbox.Label>
<Checkbox.Control />
</Checkbox>
)}
@@ -321,12 +322,13 @@ function MobileCalendarSettings(props: { controls: CalendarSettingsControls }) {
<MobileDrawer.Label>Display</MobileDrawer.Label>
<MobileDrawer.Section class="flex shrink-0 flex-col">
<Checkbox
- as="label"
checked={calendarView.displaySettings.showWeekends}
onChange={controls.changeShowWeekends}
class={DRAWER_ROW_CLASS}
>
- <span class="min-w-0 flex-1 truncate">Show weekends</span>
+ <Checkbox.Label class="min-w-0 flex-1 truncate">
+ Show weekends
+ </Checkbox.Label>
<Checkbox.Control />
</Checkbox>
</MobileDrawer.Section>
diff --git a/apps/web/src/features/calendar/components/SourceControls.test.tsx b/apps/web/src/features/calendar/components/SourceControls.test.tsx
new file mode 100644
index 0000000000..54a132899a
--- /dev/null
+++ b/apps/web/src/features/calendar/components/SourceControls.test.tsx
@@ -0,0 +1,45 @@
+/**
+ * @vitest-environment jsdom
+ */
+
+import { fireEvent, render } from '@solidjs/testing-library';
+import { createSignal } from 'solid-js';
+import { describe, expect, it, vi } from 'vitest';
+import { SourceControls } from './SourceControls';
+
+function renderControls() {
+ const onVisibilityChange = vi.fn<(id: string, visible: boolean) => void>();
+ const [visible, setVisible] = createSignal(true);
+ const { container } = render(() => (
+ <SourceControls
+ sources={[{ id: 'cal-1', name: '[email protected]', color: '#ff0000' }]}
+ isVisible={() => visible()}
+ onVisibilityChange={(id, next) => {
+ onVisibilityChange(id, next);
+ setVisible(next);
+ }}
+ />
+ ));
+ const query = (selector: string) => {
+ const element = container.querySelector(selector);
+ if (!element) throw new Error(`missing ${selector}`);
+ return element;
+ };
+ return { query, onVisibilityChange, visible };
+}
+
+describe('SourceControls', () => {
+ it('toggles when the source name is clicked', () => {
+ const { query, onVisibilityChange, visible } = renderControls();
+ fireEvent.click(query('label'));
+ expect(onVisibilityChange).toHaveBeenCalledWith('cal-1', false);
+ expect(visible()).toBe(false);
+ });
+
+ it('toggles when the checkbox control is clicked', () => {
+ const { query, onVisibilityChange, visible } = renderControls();
+ fireEvent.click(query('[id$="-control"]'));
+ expect(onVisibilityChange).toHaveBeenCalledWith('cal-1', false);
+ expect(visible()).toBe(false);
+ });
+});
diff --git a/apps/web/src/features/calendar/components/SourceControls.tsx b/apps/web/src/features/calendar/components/SourceControls.tsx
index d4d377d288..d32d8fd683 100644
--- a/apps/web/src/features/calendar/components/SourceControls.tsx
+++ b/apps/web/src/features/calendar/components/SourceControls.tsx
@@ -15,17 +15,18 @@ export function SourceControls(props: SourceControlsProps) {
<For each={props.sources}>
{(source) => (
<Checkbox
- as="label"
checked={props.isVisible(source.id)}
onChange={(checked) => props.onVisibilityChange(source.id, checked)}
class="flex w-full items-center rounded-lg px-2 py-1.5 text-xs text-ink hover:bg-hover"
>
- <span
- aria-hidden="true"
- class="size-2.5 shrink-0 rounded-sm"
- style={{ 'background-color': source.color }}
- />
- <span class="min-w-0 flex-1 truncate">{source.name}</span>
+ <Checkbox.Label class="flex min-w-0 flex-1 items-center gap-2">
+ <span
+ aria-hidden="true"
+ class="size-2.5 shrink-0 rounded-sm"
+ style={{ 'background-color': source.color }}
+ />
+ <span class="min-w-0 flex-1 truncate">{source.name}</span>
+ </Checkbox.Label>
<Checkbox.Control />
</Checkbox>
)}
diff --git a/apps/web/src/features/theme/components/ThemeTokenEditor.tsx b/apps/web/src/features/theme/components/ThemeTokenEditor.tsx
index 11182e5e06..203970dc34 100644
--- a/apps/web/src/features/theme/components/ThemeTokenEditor.tsx
+++ b/apps/web/src/features/theme/components/ThemeTokenEditor.tsx
@@ -541,13 +541,12 @@ function RampEditor(props: { tokens: readonly string[] }) {
</div>
</div>
<Checkbox
- as="label"
checked={overwrite()}
onChange={setOverwriteAll}
class="flex items-center gap-2 text-xs text-ink-muted"
>
<Checkbox.Control />
- <span>Overwrite custom stops</span>
+ <Checkbox.Label>Overwrite custom stops</Checkbox.Label>
</Checkbox>
</div>