@@ -77,6 +77,7 @@ import { hasScrollableParents } from "carbon-components-angular/utils";
7777 'cds--list-box--inline': inline,
7878 'cds--skeleton': skeleton,
7979 'cds--dropdown--disabled cds--list-box--disabled': disabled,
80+ 'cds--dropdown--readonly': readonly,
8081 'cds--dropdown--invalid': invalid,
8182 'cds--dropdown--warning cds--list-box--warning': warn,
8283 'cds--dropdown--sm cds--list-box--sm': size === 'sm',
@@ -92,8 +93,9 @@ import { hasScrollableParents } from "carbon-components-angular/utils";
9293 [ngClass]="{'a': !menuIsClosed}"
9394 [attr.aria-expanded]="!menuIsClosed"
9495 [attr.aria-disabled]="disabled"
96+ [attr.aria-readonly]="readonly"
9597 aria-haspopup="listbox"
96- (click)="disabled ? $event.stopPropagation() : toggleMenu()"
98+ (click)="disabled || readonly ? $event.stopPropagation() : toggleMenu()"
9799 (blur)="onBlur()"
98100 [attr.disabled]="disabled ? true : null">
99101 <div
@@ -224,6 +226,10 @@ export class Dropdown implements OnInit, AfterContentInit, AfterViewInit, OnDest
224226 * Set to `true` to disable the dropdown.
225227 */
226228 @Input ( ) disabled = false ;
229+ /**
230+ * Set to `true` for a readonly state.
231+ */
232+ @Input ( ) readonly = false ;
227233 /**
228234 * Set to `true` for a loading dropdown.
229235 */
@@ -514,6 +520,10 @@ export class Dropdown implements OnInit, AfterContentInit, AfterViewInit, OnDest
514520 */
515521 @HostListener ( "keydown" , [ "$event" ] )
516522 onKeyDown ( event : KeyboardEvent ) {
523+ if ( this . readonly ) {
524+ return ;
525+ }
526+
517527 if ( ( event . key === "Escape" ) && ! this . menuIsClosed ) {
518528 event . stopImmediatePropagation ( ) ; // don't unintentionally close other widgets that listen for Escape
519529 }
0 commit comments