From 64423344ea4ae4410013579d21d11872007bea9b Mon Sep 17 00:00:00 2001 From: Alex Rawlings Date: Tue, 11 Aug 2026 12:00:57 -0600 Subject: [PATCH] Keep icon buttons centered while pressed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The platform button's pressed style is a translate, which overwrites the same custom property a translate utility uses for centering — so the suggestion "+" and the arc split button both jumped mid-click. --- src/__tests__/components/ArcOverlay.test.tsx | 17 +++++++++++++++++ .../components/TokenChip.suggestions.test.tsx | 9 +++++++++ src/components/ArcOverlay.tsx | 6 ++++-- src/components/TokenChip.tsx | 5 +++-- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/__tests__/components/ArcOverlay.test.tsx b/src/__tests__/components/ArcOverlay.test.tsx index 21132a69..3c274ff8 100644 --- a/src/__tests__/components/ArcOverlay.test.tsx +++ b/src/__tests__/components/ArcOverlay.test.tsx @@ -171,6 +171,23 @@ describe('ArcOverlay', () => { expect(screen.getByTestId('split-arc-btn').className).toContain('phrase-focused'); }); + it('centers the split button on the arc midpoint without a translate', () => { + // The platform button's pressed style is a translate, so translate-centering breaks while held. + const phraseLink = makePhraseLink('p1', ['tok-a', 'tok-b']); + render( + , + ); + + const button = screen.getByTestId('split-arc-btn'); + expect(button).toHaveStyle({ transform: 'translate(-50%, -50%)' }); + expect(button.className).not.toMatch(/translate/); + }); + it('calls onArcSplit and clears hover state when split button is clicked', async () => { const onArcSplit = jest.fn(); const onSplitHoverChange = jest.fn(); diff --git a/src/__tests__/components/TokenChip.suggestions.test.tsx b/src/__tests__/components/TokenChip.suggestions.test.tsx index cc37e02d..dea253f2 100644 --- a/src/__tests__/components/TokenChip.suggestions.test.tsx +++ b/src/__tests__/components/TokenChip.suggestions.test.tsx @@ -691,6 +691,15 @@ describe('TokenChip suggestion + button', () => { expect(addButton).toHaveAttribute('aria-hidden', 'true'); }); + it('centers itself in the gloss field without a translate', () => { + // The platform button's pressed style is a translate, so translate-centering breaks while held. + renderChip(makeWordToken('tok-new', 'bank'), { initialAnalysis: homographBankPool('finance') }); + + const addButton = screen.getByTestId('suggestion-add'); + expect(addButton).toHaveClass('tw:inset-y-0', 'tw:my-auto'); + expect(addButton.className).not.toMatch(/translate/); + }); + it('force-opens the dropdown over already-typed text and selecting replaces the draft', async () => { const onSave = jest.fn(); renderChip(makeWordToken('tok-new', 'bank'), { diff --git a/src/components/ArcOverlay.tsx b/src/components/ArcOverlay.tsx index 9451c45c..00f54de3 100644 --- a/src/components/ArcOverlay.tsx +++ b/src/components/ArcOverlay.tsx @@ -306,9 +306,11 @@ export function ArcOverlay({