Skip to content

Commit

Permalink
fix(select): prevent navigation to disabled option from keyboard (#1427)
Browse files Browse the repository at this point in the history
  • Loading branch information
yggg committed May 27, 2019
1 parent ee07fbc commit 657d8ae
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
7 changes: 3 additions & 4 deletions src/framework/theme/components/select/option.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { NbSelectComponent } from './select.component';
template: `
<nb-checkbox *ngIf="withCheckbox"
[value]="selected"
[disabled]="disabledAttribute"
[disabled]="disabled"
aria-hidden="true">
</nb-checkbox>
<ng-content></ng-content>
Expand All @@ -49,7 +49,7 @@ export class NbOptionComponent<T> implements OnDestroy, NbFocusableOption {

@Input()
get disabled(): boolean {
return this._disabled;
return this._disabled || this.disabledByGroup;
}
set disabled(value: boolean) {
this._disabled = convertToBoolProperty(value);
Expand Down Expand Up @@ -103,8 +103,7 @@ export class NbOptionComponent<T> implements OnDestroy, NbFocusableOption {

@HostBinding('attr.disabled')
get disabledAttribute(): '' | null {
const disabled = this.disabledByGroup || this.disabled;
return disabled ? '' : null;
return this.disabled ? '' : null;
}

@HostBinding('tabIndex')
Expand Down
9 changes: 0 additions & 9 deletions src/framework/theme/components/select/select.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -803,13 +803,4 @@ describe('NbOptionComponent disabled', () => {
const option = fixture.debugElement.query(By.directive(NbOptionComponent));
expect(option.attributes.disabled).toEqual('');
}));

it('should not change disabled property if group disabled changes', fakeAsync(() => {
testComponent.optionGroupDisabled = true;
fixture.detectChanges();
flush();
fixture.detectChanges();

expect(optionComponent.disabled).toEqual(false);
}));
});

0 comments on commit 657d8ae

Please sign in to comment.