-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(autocomplete): update input element disabled state (#2555)
(cherry picked from commit 23e59ba)
- Loading branch information
Showing
8 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/playground/with-layout/autocomplete/autocomplete-disabled.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<nb-card size="small"> | ||
<nb-card-body class="example-items-col"> | ||
|
||
<button (click)="toggleDisabled()" nbButton>Toggle disabled</button> | ||
|
||
<label> | ||
<span class="label">Disabled via <i>disabled</i> attribute</span> | ||
<input [nbAutocomplete]="auto" | ||
[disabled]="disabled" | ||
nbInput | ||
type="text" | ||
placeholder="Plain input" /> | ||
</label> | ||
|
||
<label> | ||
<span class="label">Disabled via <i>formControl</i></span> | ||
<input [nbAutocomplete]="auto" | ||
[formControl]="inputFormControl" | ||
nbInput | ||
type="text" | ||
placeholder="Form control" /> | ||
</label> | ||
|
||
<nb-autocomplete #auto> | ||
<nb-option *ngFor="let option of options" [value]="option"> | ||
{{ option }} | ||
</nb-option> | ||
</nb-autocomplete> | ||
|
||
</nb-card-body> | ||
</nb-card> |
4 changes: 4 additions & 0 deletions
4
src/playground/with-layout/autocomplete/autocomplete-disabled.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.label { | ||
display: block; | ||
margin-bottom: 0.5rem; | ||
} |
28 changes: 28 additions & 0 deletions
28
src/playground/with-layout/autocomplete/autocomplete-disabled.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* @license | ||
* Copyright Akveo. All Rights Reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*/ | ||
|
||
import { ChangeDetectionStrategy, Component } from '@angular/core'; | ||
import { FormControl } from '@angular/forms'; | ||
|
||
@Component({ | ||
templateUrl: './autocomplete-disabled.component.html', | ||
styleUrls: ['./autocomplete-disabled.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class AutocompleteDisabledComponent { | ||
options = ['Option 1', 'Option 2', 'Option 3']; | ||
disabled = true; | ||
inputFormControl = new FormControl(); | ||
|
||
toggleDisabled() { | ||
this.disabled = !this.disabled; | ||
if (this.disabled) { | ||
this.inputFormControl.disable(); | ||
} else { | ||
this.inputFormControl.enable(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters