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(channel): use semantic button state for reaction chips (#7191)

Peter Chinman871bc1858a9d
diff --git a/apps/web/src/features/channel/Message/ReactionChip.tsx b/apps/web/src/features/channel/Message/ReactionChip.tsx
index bc624b0feb..bc9cdaac14 100644
--- a/apps/web/src/features/channel/Message/ReactionChip.tsx
+++ b/apps/web/src/features/channel/Message/ReactionChip.tsx
@@ -79,6 +79,7 @@ export function ReactionChip(props: ReactionChipProps) {
data-message-reaction-chip
data-emoji={props.emoji}
data-user-reacted={props.selected ? '' : undefined}
+ aria-pressed={!!props.selected}
noTouchResize
ref={(el) =>
touchHandler(el, () => ({
@@ -92,10 +93,6 @@ export function ReactionChip(props: ReactionChipProps) {
variant={props.selected ? 'accent' : 'outline'}
class={cn(
'flex flex-row items-center h-7 min-w-7 gap-1 rounded-full',
- // Mix toward black, not ink. An ink wash lightens a dark theme, so
- // it cannot show "you reacted" in both themes.
- props.selected &&
- 'bg-[color-mix(in_oklch,oklch(0_0_0)_16%,var(--color-control))] dark-mode:bg-[color-mix(in_oklch,oklch(0_0_0)_34%,var(--color-control))]',
!props.interactive && 'pointer-events-auto'
)}
disabled={!props.interactive}
diff --git a/apps/web/src/features/channel/Message/tests/reactions.test.tsx b/apps/web/src/features/channel/Message/tests/reactions.test.tsx
index a6ae1a6046..13af487a02 100644
--- a/apps/web/src/features/channel/Message/tests/reactions.test.tsx
+++ b/apps/web/src/features/channel/Message/tests/reactions.test.tsx
@@ -5,6 +5,7 @@
import type { MessageData } from '@core/messages/types';
import { render, screen } from '@solidjs/testing-library';
import userEvent from '@testing-library/user-event';
+import { createSignal } from 'solid-js';
import { describe, expect, it, vi } from 'vitest';
import { formatReactorNames } from '../ReactionChip';
import { Reactions } from '../Reactions';
@@ -48,15 +49,16 @@ describe('Reactions', () => {
expect(screen.queryByRole('button', { name: 'Add reaction' })).toBeNull();
});
- it('dims a reaction the current user already added', () => {
+ it('marks only the current user’s reactions as pressed and updates with membership', () => {
+ const [reactions, setReactions] = createSignal([
+ { emoji: '❤️', users: ['user-1', 'user-2'] },
+ { emoji: '👍', users: ['user-3'] },
+ ]);
render(() => (
<Root
message={{
...baseMessage,
- reactions: [
- { emoji: '❤️', users: ['user-1', 'user-2'] },
- { emoji: '👍', users: ['user-3'] },
- ],
+ reactions: reactions(),
}}
actions={{
onReact: () => undefined,
@@ -66,21 +68,27 @@ describe('Reactions', () => {
</Root>
));
- const chips = () =>
+ const heart = screen.getByRole('button', { name: /❤️/u, pressed: true });
+ const thumb = screen.getByRole('button', { name: /👍/u, pressed: false });
+
+ expect(heart.hasAttribute('data-user-reacted')).toBe(true);
+ expect(thumb.hasAttribute('data-user-reacted')).toBe(false);
+
+ setReactions([
+ { emoji: '❤️', users: ['user-2'] },
+ { emoji: '👍', users: ['user-3', 'user-1'] },
+ ]);
+
+ expect(
screen
- .getAllByRole('button')
- .filter((el) => el.hasAttribute('data-message-reaction-chip'));
- const heart = chips().find((el) => el.dataset.emoji === '❤️');
- const thumb = chips().find((el) => el.dataset.emoji === '👍');
-
- expect(heart?.hasAttribute('data-user-reacted')).toBe(true);
- expect(heart?.className).toContain(
- 'bg-[color-mix(in_oklch,oklch(0_0_0)_16%,var(--color-control))]'
- );
- expect(thumb?.hasAttribute('data-user-reacted')).toBe(false);
- expect(thumb?.className).not.toContain(
- 'bg-[color-mix(in_oklch,oklch(0_0_0)_16%,var(--color-control))]'
- );
+ .getByRole('button', { name: /❤️/u, pressed: false })
+ .hasAttribute('data-user-reacted')
+ ).toBe(false);
+ expect(
+ screen
+ .getByRole('button', { name: /👍/u, pressed: true })
+ .hasAttribute('data-user-reacted')
+ ).toBe(true);
});
it('calls onReact with chip emoji when a reaction chip is clicked', async () => {