Skip to content

fix: allow text in read-only components to be selected#4417

Open
TrevorBurnham wants to merge 2 commits intocloudscape-design:mainfrom
TrevorBurnham:read-only-selectable-text
Open

fix: allow text in read-only components to be selected#4417
TrevorBurnham wants to merge 2 commits intocloudscape-design:mainfrom
TrevorBurnham:read-only-selectable-text

Conversation

@TrevorBurnham
Copy link
Copy Markdown
Contributor

Fixes #4411

This PR modifies the styles on DateRangePicker, FileTokenGroup, Select and Multiselect to make text selectable.

Testing

I've added a read-only toggle to the demo pages and was able to manually test each of these.

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

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

@TrevorBurnham TrevorBurnham requested a review from a team as a code owner April 8, 2026 18:52
@TrevorBurnham TrevorBurnham requested review from jperals and removed request for a team April 8, 2026 18:52
@TrevorBurnham TrevorBurnham changed the title Allow text in read-only components to be selected fix: Allow text in read-only components to be selected Apr 8, 2026
@TrevorBurnham TrevorBurnham changed the title fix: Allow text in read-only components to be selected fix: allow text in read-only components to be selected Apr 8, 2026
@TrevorBurnham TrevorBurnham force-pushed the read-only-selectable-text branch from 227fc00 to 119d85c Compare April 8, 2026 19:21
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.38%. Comparing base (7029006) to head (8de254f).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4417   +/-   ##
=======================================
  Coverage   97.38%   97.38%           
=======================================
  Files         928      928           
  Lines       29200    29200           
  Branches    10565    10564    -1     
=======================================
  Hits        28435    28435           
- Misses        718      759   +41     
+ Partials       47        6   -41     

☔ 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.

@jperals
Copy link
Copy Markdown
Member

jperals commented Apr 15, 2026

Would it be possible to add coverage, maybe with the Selection API? https://developer.mozilla.org/en-US/docs/Web/API/Selection


// read-only in-filtering-token (i.e. for property filter readOnlyOperations)
// should retain standard borders, only the icon changes
&.readonly:not(&.disabled):not(&.in-filtering-token) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Note: probably a minor use case, but the :not(&.in-filtering-token) excludes from this fix read-only operator selectors in property filter:
Image

At the same time, we would prefer placeholder text to not be selectable, because that comes with collateral a11y issues (if it is interactive, it will have other requirements such as contrast):

Image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've moved the user-select: text to a separate &.readonly:not(&.disabled) rule that also covers filtering tokens. I've also added user-select: none to .placeholder.

- Apply `user-select: text` to all read-only button-triggers (including
  those inside property-filter tokens, i.e. `readOnlyOperations`), while
  keeping `form-readonly-element` borders scoped to the non-filtering
  case. Fixes the gap where read-only property-filter operator text was
  still unselectable.
- Set `user-select: none` on the custom placeholder spans in Select
  (`.placeholder`) and DateRangePicker (`.label-text`). When these
  components are read-only without a value, the trigger renders
  placeholder text; preserving its non-selectable nature avoids
  accessibility concerns that accompany selectable/interactive text.
- Add a DateRangePicker integration test that programmatically selects
  the read-only trigger's contents via the Selection API and asserts
  the selected string contains the rendered date values.
@TrevorBurnham TrevorBurnham force-pushed the read-only-selectable-text branch from 8de254f to 2998c7c Compare May 5, 2026 21:17
@TrevorBurnham
Copy link
Copy Markdown
Contributor Author

I've rebased the branch, added test coverage (see the new "Read-only mode" describe block), and addressed your comments

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.

[Bug]: Text in read-only date range picker is unselectable

2 participants