Skip to content

Commit 6db4781

Browse files
committed
refactor(aria/combobox): make input readonly when disabled
1 parent d1b075b commit 6db4781

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
@@ -547,6 +547,13 @@ describe('Combobox', () => {
547547
expect(inputElement.getAttribute('aria-disabled')).toBe('true');
548548
});
549549

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

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import type {ComboboxPopup} from './simple-combobox-popup';
5353
'[attr.aria-haspopup]': '_pattern.popupType()',
5454
'[attr.tabindex]': 'disabled() && !softDisabled() ? -1 : null',
5555
'[attr.disabled]': 'disabled() && !softDisabled() ? "" : null',
56+
'[attr.readonly]': 'disabled() && _pattern.isEditable() ? "" : null',
5657
'(keydown)': '_pattern.onKeydown($event)',
5758
'(focusin)': '_pattern.onFocusin()',
5859
'(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)