Skip to content

fix(dropdown-select): make readonly prevent opening and changing the value - #2568

Merged
amir-ba merged 4 commits into
telekom:mainfrom
khushi-git-7:fix/2544-dropdown-select-readonly
Nov 12, 2026
Merged

amir-ba merged 4 commits into
telekom:mainfrom
khushi-git-7:fix/2544-dropdown-select-readonly

Conversation

@khushi-git-7

@khushi-git-7 khushi-git-7 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2544

@maomaoZH @amir-ba could one of you review this?

readonly on scale-dropdown-select was accepted but never implemented. With this change a read-only dropdown:

  • doesn't open on click: setOpen() refuses to open for readonly. It can still close, so blur works even if readonly is set while the list is open
  • ignores the keyboard: handleKeyDown returns after emitting scale-keydown, so arrow keys, Enter, Space, Home/End and type-to-select do nothing
  • can't change value through an option click: handleOptionClick checks readonly as well
  • has aria-readonly="true" on the combobox
  • gets the read-only look from scale-textarea (--border-color-readonly, --background-readonly), and no hover styles

It stays in the tab order and always shows the focus outline. That matches a native read-only input and the ARIA combobox pattern, and keeps it different from disabled. If you'd rather drop it from the tab order, it's a one-line change.

Tests: four new spec tests under "when readonly":

  • focusable and aria-readonly
  • no open and no value change on click
  • no open and no value change for ArrowDown, Enter, Space, End and a typed letter
  • still closes on blur when readonly is set while open

I ran build-pr on my fork. Everything passes with the change, including e2e and visual tests. With only the source change reverted, the new tests fail and nothing else does.

One heads-up: the e2e test "should skip disabled options when typing" failed once on my fork and passed on a rerun with no changes. It types c, e quickly against the 500 ms type-to-select timeout, so it looks timing-sensitive and is unrelated to readonly.

Copilot AI balanced review requested due to automatic review settings November 3, 2026 19:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The readonly guard prevents dismissal of an already-open dropdown, and readonly fields with a non-first selection lack a keyboard focus outline.

2 open issues
What changed in this PR

Implements readonly behavior for scale-dropdown-select, addressing #2544 by blocking user interaction and adding read-only styling while preserving tab access.

Changes:

  • Guards opening, keyboard actions, and option selection when read-only.
  • Adds aria-readonly, read-only colors, and hover-style exclusions.
  • Adds three tests covering tab order, accessibility attributes, and blocked mouse and keyboard interaction.
File Description
packages/​components/​src/​components/​dropdown-select/​dropdown-select.tsx Adds read-only interaction guards and the ARIA attribute.
packages/​components/​src/​components/​dropdown-select/​dropdown-select.spec.ts Tests read-only accessibility and interaction behavior.
packages/​components/​src/​components/​dropdown-select/​dropdown-select.css Adds read-only styling and suppresses hover and active effects.

Review effort: Balanced

@khushi-git-7

Copy link
Copy Markdown
Contributor Author

Hi @amir-ba, a gentle nudge on this one when you have a moment. It's still up to date with main, merges cleanly, and the checks pass. Happy to change anything.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@amir-ba amir-ba left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, I added a simple fix to have the storybook docs also allow toggling this .
I will merge when pipeline finishes

@amir-ba
amir-ba merged commit fd8da4b into telekom:main Nov 12, 2026
17 of 18 checks passed
@khushi-git-7

Copy link
Copy Markdown
Contributor Author

Thanks @amir-ba for the review, the merge, and for extending the Storybook docs so the toggle can be tried there too.

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.

scale-dropdown-select: readonly prop has no effect

3 participants