Skip to content

Commit 306fe00

Browse files
authored
refactor(aria/combobox): make input readonly when disabled (#33187)
1 parent 619a53d commit 306fe00

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/aria/simple-combobox/simple-combobox.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,13 @@ describe('Combobox', () => {
548548
expect(inputElement.getAttribute('aria-disabled')).toBe('true');
549549
});
550550

551+
it('should make the input read-only when disabled and softDisabled is true', () => {
552+
fixture.componentInstance.disabled.set(true);
553+
fixture.detectChanges();
554+
555+
expect(inputElement.getAttribute('readonly')).toBe('');
556+
});
557+
551558
it('should block interactions when disabled', () => {
552559
fixture.componentInstance.disabled.set(true);
553560
fixture.detectChanges();

src/aria/simple-combobox/simple-combobox.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import type {ComboboxPopup} from './simple-combobox-popup';
5858
'[attr.tabindex]':
5959
'disabled() && !softDisabled() ? -1 : (tabIndex() !== undefined ? tabIndex() : 0)',
6060
'[attr.disabled]': 'disabled() && !softDisabled() ? "" : null',
61+
'[attr.readonly]': 'disabled() && _pattern.isEditable() ? "" : null',
6162
'(keydown)': '_pattern.onKeydown($event)',
6263
'(focusin)': '_pattern.onFocusin()',
6364
'(focusout)': '_pattern.onFocusout($event)',

src/components-examples/aria/simple-combobox/simple-combobox-autocomplete-disabled/simple-combobox-autocomplete-disabled-example.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class SimpleComboboxAutocompleteDisabledExample {
3434
readonly combobox = viewChild(Combobox);
3535

3636
popupExpanded = signal(false);
37-
searchString = signal('United States of America');
37+
searchString = signal('Select a country');
3838
selectedOption = signal<string[]>([]);
3939

4040
/** The query string used to filter the list of countries. */

0 commit comments

Comments
 (0)