An open source design system that's fully customizable and agent ready
TypeScript
fix(Citation): only show pointer cursor when source has a url (#4134) (#4141)
Gaurav Yadav81cd3386542e
diff --git a/.changeset/citation-cursor-non-interactive.md b/.changeset/citation-cursor-non-interactive.mdnew file mode 100644index 0000000000..8810ebf62b--- /dev/null+++ b/.changeset/citation-cursor-non-interactive.md@@ -0,0 +1,6 @@+---+'@astryxdesign/core': patch+---++[fix] Citation: a non-interactive citation (no `source.url`) now keeps the default cursor instead of showing a pointer, so only linked citations look clickable. The pointer cursor is applied alongside the existing hover treatment for both the `label` and `number` variants (#4134).+@MeGaurav4diff --git a/packages/core/src/Citation/Citation.test.tsx b/packages/core/src/Citation/Citation.test.tsxindex 865469918f..efc3ae653f 100644--- a/packages/core/src/Citation/Citation.test.tsx+++ b/packages/core/src/Citation/Citation.test.tsx@@ -20,6 +20,7 @@ const probe = stylex.create({secondaryText: {color: colorVars['--color-text-secondary']},accentText: {color: colorVars['--color-text-accent']},badgeBackground: {backgroundColor: colorVars['--color-accent-muted']},+ pointerCursor: {cursor: 'pointer'},});function atomicClasses(style: (typeof probe)[keyof typeof probe]): string[] {@@ -118,4 +119,54 @@ describe('Citation', () => {expect(el.classList.contains(cls)).toBe(true);}});++ // The interactive (pointer) treatment is keyed on `source.url`: a citation+ // with no url is non-interactive and must keep the default cursor.+ const noUrlSource = {title: 'No link'};++ it('does not use the pointer cursor without a url in the label variant', () => {+ render(<Citation source={noUrlSource} number={1} data-testid="citation" />);+ const el = screen.getByTestId('citation');+ for (const cls of atomicClasses(probe.pointerCursor)) {+ expect(el.classList.contains(cls)).toBe(false);+ }+ });++ it('uses the pointer cursor with a url in the label variant', () => {+ render(<Citation source={source} number={1} data-testid="citation" />);+ const el = screen.getByTestId('citation');+ for (const cls of atomicClasses(probe.pointerCursor)) {+ expect(el.classList.contains(cls)).toBe(true);+ }+ });++ it('does not use the pointer cursor without a url in the number variant', () => {+ render(+ <Citation+ source={noUrlSource}+ number={1}+ variant="number"+ data-testid="citation"+ />,+ );+ const el = screen.getByTestId('citation');+ for (const cls of atomicClasses(probe.pointerCursor)) {+ expect(el.classList.contains(cls)).toBe(false);+ }+ });++ it('uses the pointer cursor with a url in the number variant', () => {+ render(+ <Citation+ source={source}+ number={1}+ variant="number"+ data-testid="citation"+ />,+ );+ const el = screen.getByTestId('citation');+ for (const cls of atomicClasses(probe.pointerCursor)) {+ expect(el.classList.contains(cls)).toBe(true);+ }+ });});diff --git a/packages/core/src/Citation/Citation.tsx b/packages/core/src/Citation/Citation.tsxindex 5c81a56f4f..b880ed677f 100644--- a/packages/core/src/Citation/Citation.tsx+++ b/packages/core/src/Citation/Citation.tsx@@ -61,7 +61,6 @@ const styles = stylex.create({paddingInline: spacingVars['--spacing-2'],marginInlineStart: spacingVars['--spacing-0-5'],textDecoration: 'none',- cursor: 'pointer',transitionProperty: 'background-color, border-color, color',transitionDuration: durationVars['--duration-fast-max'],transitionTimingFunction: easeVars['--ease-standard'],@@ -77,6 +76,9 @@ const styles = stylex.create({whiteSpace: 'nowrap',minWidth: 0,},+ labelInteractive: {+ cursor: 'pointer',+ },labelHover: {backgroundColor: {':hover': {@@ -108,11 +110,13 @@ const styles = stylex.create({height: spacingVars['--spacing-5'],paddingInline: spacingVars['--spacing-1'],textDecoration: 'none',- cursor: 'pointer',transitionProperty: 'background-color',transitionDuration: durationVars['--duration-fast-max'],transitionTimingFunction: easeVars['--ease-standard'],},+ numberInteractive: {+ cursor: 'pointer',+ },numberHover: {backgroundColor: {// Explicit default for the same reason as labelHover's color: a@@ -191,6 +195,7 @@ export function Citation({stylex.props(styles.number,href != null && styles.numberHover,+ href != null && styles.numberInteractive,xstyle,),className,@@ -215,6 +220,7 @@ export function Citation({styles.label,icon != null && styles.labelWithIcon,href != null && styles.labelHover,+ href != null && styles.labelInteractive,xstyle,),className,