astryx icon indicating copy to clipboard operation
astryx copied to clipboard

[Bug] Token: a clickable token ignores the supplied button name

Open duytbp opened this issue 2 weeks ago • 4 comments

Description

A clickable Token's inner button keeps its default accessible name when the caller supplies aria-label. The override lands on the outer span. With repeated chip labels, the buttons can have identical names even though the caller supplies context for each action.

In Token.tsx, the clickable branch spreads the remaining props onto the container. It sets the button's aria-label from the internal naming context and forwards a caller's aria-labelledby to the button. I expected a caller's explicit aria-label to name the button when no aria-labelledby supplies a name. The visible text and the separate remove button should keep their existing labels.

Reproduction

import { Token } from '@astryxdesign/core/Token';

export function Example() {
  return (
    <>
      <Token label="Invoice" aria-label="Invoice for Project A" onClick={() => {}} />
      <Token label="Invoice" aria-label="Invoice for Project B" onClick={() => {}} />
    </>
  );
}
  1. Render the example and inspect both buttons in the accessibility tree.
  2. Both buttons are named “Invoice”. Their distinct aria-label values appear on the surrounding spans.
  3. Expect the buttons to be named “Invoice for Project A” and “Invoice for Project B”.

Passing aria-labelledby with a reference to each action's full name works around the problem.

Astryx Version

@astryxdesign/[email protected]. The relevant implementation is unchanged in v0.7.17 and on main.

Environment

Reproduced with React 19 and jsdom using a role-based accessible name query. Checked the relevant source on v0.7.17 and main.

duytbp avatar Nov 21 '26 07:11 duytbp

Hi! I'd like to pick this up if no one's on it. My plan:

  • In the clickable branch of Token.tsx, take aria-label out of the props that get spread onto the container and pass it to the inner button instead.
  • Name the button in this order: the caller's aria-labelledby, then the caller's aria-label, then the current internal default. The visible text and the separate remove button keep their existing labels.
  • Add a test with two Invoice tokens that have different aria-labels, checking that each button gets its own name and that the outer span no longer carries the label.

Happy to adjust if you'd rather handle the precedence differently.

Mittalnew avatar Nov 21 '26 14:11 Mittalnew

🤖 (Posted by Cindy's agent.) Thanks for the report, @duytbp. I confirmed it on main: in a clickable Token, the remaining props, aria-label included, are spread onto the outer span, while the inner button takes its name from the label, so two "Invoice" tokens end up with identically named buttons.

@Mittalnew, thanks for the plan. The precedence you describe (the caller's aria-labelledby, then aria-label, then the current default) matches how the button already handles aria-labelledby. Please go ahead, link this issue in the PR, and include the two-"Invoice" test you described.

cixzhang avatar Nov 22 '26 15:11 cixzhang

@cixzhang is this issue still open to be worked on? because i dont see any pr raised yet and its been 3 days since any activity, if its open i would love to pick it up

Geervan avatar Nov 25 '26 05:11 Geervan

🤖 (Posted by Cindy's agent.) Thanks for offering, @Geervan, and @Mittalnew too! A fix for this is up in #13776 by @rheatkhs: a clickable Token now passes the caller's aria-label to its inner button. It's in review now, so this one is covered. If you're looking for something to pick up, there are open follow-ups such as the test-file item in #13746 and the touch hit area and icon imports in #12018.

cixzhang avatar Nov 25 '26 16:11 cixzhang