Skip to content

fix: Make truncated filename tooltip keyboard accessible (file-token-group)#4157

Merged
Who-is-PS merged 11 commits intomainfrom
dev-v3-philosr-file-token-group-fix
Feb 9, 2026
Merged

fix: Make truncated filename tooltip keyboard accessible (file-token-group)#4157
Who-is-PS merged 11 commits intomainfrom
dev-v3-philosr-file-token-group-fix

Conversation

@Who-is-PS
Copy link
Member

Description

Adds keyboard accessibility to the file token tooltip. The filename container is now focusable (tabIndex={0}) with onFocus/onBlur handlers, allowing keyboard users to view the full filename when text is truncated.

Related links, issue #, if available:
AWSUI-61600

How has this been tested?

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov
Copy link

codecov bot commented Jan 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.19%. Comparing base (fb474aa) to head (5731bc5).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4157      +/-   ##
==========================================
- Coverage   97.19%   97.19%   -0.01%     
==========================================
  Files         886      886              
  Lines       25996    26005       +9     
  Branches     9415     9418       +3     
==========================================
+ Hits        25267    25275       +8     
- Misses        723      724       +1     
  Partials        6        6              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Who-is-PS Who-is-PS marked this pull request as ready for review January 5, 2026 18:37
@Who-is-PS Who-is-PS requested a review from a team as a code owner January 5, 2026 18:37
@Who-is-PS Who-is-PS requested review from a team, amanabiy, ernst-dev and georgylobko and removed request for a team, amanabiy and ernst-dev January 5, 2026 18:37
@Who-is-PS
Copy link
Member Author

Received translations from i18n package (CR-252051089) and merged them into main of AWS-UI-Components-I18n

@Who-is-PS Who-is-PS requested a review from avinashbot February 6, 2026 09:56
checkTruncation();

// Check on window resize
window.addEventListener('resize', checkTruncation);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are things other than a full window resize that can cause the truncation to trigger (opening panels, content changes, layout updates) so a ResizeObserver (we have a useResizeObserver) might be more "correct" here. But I think it's fine — the max width of the token is 230px, it's probably very unlikely that the component will be placed in a layout that narrow, so there's no need to pay that performance tax unless we have to.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend to switch to the resize observer as it has a better performance than the resize event

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Switched to useResizeObserver to observe the filename container element directly. This gives us better performance and also handles container-level resizes (panels, layout changes) that the window resize event would miss.

avinashbot
avinashbot previously approved these changes Feb 6, 2026
const wrapper = render({ items: [{ file: file3 }], alignment: 'horizontal' });

fireEvent.focus(wrapper.findFileToken(1)!.findFileName().getElement());
expect(document.querySelector(`.${tooltipStyles.root}`)).not.toBeNull();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should you check the content of the tooltip instead of 'not null'?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Updated the assertions to verify the tooltip displays the correct file name.


expect(wrapper.findFileToken(1)!.findRemoveButton().getElement()).toHaveFocus();
// After dismissal, focus moves to the filename container (first focusable element in the token)
const fileNameElement = wrapper.findFileToken(1)!.findFileName().getElement().parentElement;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[non-blocking]: I'd be easier to search by the container classname - file-name-button

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Updated to use the file-name-container classname selector instead of parentElement.

>
<InternalSpaceBetween direction="vertical" size="xxxs">
<div
className={styles['file-name-button']}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] "button" in the classname is a bit misleading. I'd suggest to rename it to file-name-container instead

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Renamed to file-name-container


fireEvent.mouseEnter(wrapper.findFileToken(1)!.findFileName().getElement());
expect(document.querySelector(`.${tooltipStyles.root}`)).not.toBeNull();
expect(document.querySelector(`.${tooltipStyles.root}`)).toHaveTextContent(file3.name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[non-blocking, could be a follow-up] Should you use test wrapper instead such as createWrapper().findTooltip()?

@Who-is-PS Who-is-PS added this pull request to the merge queue Feb 9, 2026
Merged via the queue into main with commit 8ae8f78 Feb 9, 2026
50 checks passed
@Who-is-PS Who-is-PS deleted the dev-v3-philosr-file-token-group-fix branch February 9, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants