Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(Token): a removable token cut by its width keeps its remove button at full size (#9621)

Ojas Mutreja13acdeb7d518
diff --git a/.changeset/token-remove-button-keeps-size.md b/.changeset/token-remove-button-keeps-size.md
new file mode 100644
index 0000000000..3f58c5c2e0
--- /dev/null
+++ b/.changeset/token-remove-button-keeps-size.md
@@ -0,0 +1,6 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] A removable `Token` that its width cuts off now keeps its 16 by 16 remove button. The button used to shrink to 12 px wide, so its focus ring drew as an oval and its press target narrowed to 20 by 24 px. Only the label is cut now. (#9599)
+@HelloOjasMutreja
diff --git a/packages/core/src/Token/Token.test.tsx b/packages/core/src/Token/Token.test.tsx
index 630ec93132..c44e40666b 100644
--- a/packages/core/src/Token/Token.test.tsx
+++ b/packages/core/src/Token/Token.test.tsx
@@ -111,6 +111,29 @@ describe('Token', () => {
expect(handleRemove).toHaveBeenCalledTimes(1);
});
+ it.each([
+ ['static', {}],
+ ['clickable', {onClick: vi.fn()}],
+ ['link', {href: '/filters/open'}],
+ ])(
+ 'keeps the remove button from shrinking when a %s token is cut by its width',
+ (_structure, props) => {
+ render(
+ <div style={{width: 60}}>
+ <Token
+ label="Location: Ho Chi Minh City"
+ onRemove={vi.fn()}
+ {...props}
+ />
+ </div>,
+ );
+ const removeButton = screen.getByRole('button', {
+ name: 'Remove Location: Ho Chi Minh City',
+ });
+ expect(getComputedStyle(removeButton).flexShrink).toBe('0');
+ },
+ );
+
it('stops propagation when remove button is clicked', () => {
const handleRemove = vi.fn();
const handleClick = vi.fn();
diff --git a/packages/core/src/Token/Token.tsx b/packages/core/src/Token/Token.tsx
index 8ec6d7822b..9cb5b91be4 100644
--- a/packages/core/src/Token/Token.tsx
+++ b/packages/core/src/Token/Token.tsx
@@ -193,6 +193,8 @@ const styles = stylex.create({
borderRadius: radiusVars['--radius-full'],
width: '16px',
height: '16px',
+ // A token cut by its width shrinks only its label, not the button.
+ flexShrink: 0,
color: 'inherit',
'::after': {
content: '""',