-
Notifications
You must be signed in to change notification settings - Fork 477
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(kit): don't allow disabled options to be selected (#5985)
Co-authored-by: taiga-family-bot <[email protected]>
- Loading branch information
1 parent
f6e7877
commit 948be22
Showing
7 changed files
with
92 additions
and
1 deletion.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
projects/demo-playwright/tests/kit/combo-box/combobox.spec.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,27 @@ | ||
import {TuiDocumentationPagePO, tuiGoto} from '@demo-playwright/utils'; | ||
import {expect, test} from '@playwright/test'; | ||
|
||
const {describe} = test; | ||
|
||
describe(`ComboBox`, () => { | ||
test(`Don't allow disabled options to be selected by typing them`, async ({page}) => { | ||
await tuiGoto(page, `components/combo-box`); | ||
|
||
const documentationPage = new TuiDocumentationPagePO(page); | ||
const example = documentationPage.getExample(`#ignore-disabled`); | ||
const input = example.locator(`tui-combo-box input[tuiTextfield]`); | ||
|
||
await example.scrollIntoViewIfNeeded(); | ||
await input.click(); | ||
await expect(page).toHaveScreenshot(`01-combobox-dont-allow-disabled-01.png`); | ||
|
||
await input.fill(`Graham Chapman`); | ||
await expect(page).toHaveScreenshot(`01-combobox-dont-allow-disabled-02.png`); | ||
|
||
await page.click(`body`); | ||
await expect(page).toHaveScreenshot(`01-combobox-dont-allow-disabled-03.png`); | ||
|
||
await input.click(); | ||
await expect(page).toHaveScreenshot(`01-combobox-dont-allow-disabled-04.png`); | ||
}); | ||
}); |
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
24 changes: 24 additions & 0 deletions
24
projects/demo/src/modules/components/combo-box/examples/7/index.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,24 @@ | ||
<tui-combo-box | ||
[stringify]="stringify" | ||
[(ngModel)]="value" | ||
> | ||
Find the best employees | ||
<input | ||
placeholder="Type a name" | ||
tuiTextfield | ||
/> | ||
<ng-container *tuiDataList> | ||
<tui-data-list> | ||
<button | ||
*ngFor="let item of items | tuiFilterByInputWith: stringify" | ||
tuiOption | ||
[disabled]="item.disabled" | ||
[value]="item" | ||
> | ||
{{ stringify(item) }} | ||
</button> | ||
</tui-data-list> | ||
</ng-container> | ||
</tui-combo-box> | ||
|
||
<p class="tui-space_top-2">Selected value: {{ value | json }}</p> |
25 changes: 25 additions & 0 deletions
25
projects/demo/src/modules/components/combo-box/examples/7/index.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,25 @@ | ||
import {Component} from '@angular/core'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {encapsulation} from '@demo/emulate/encapsulation'; | ||
|
||
@Component({ | ||
selector: 'tui-combo-box-example-7', | ||
templateUrl: './index.html', | ||
encapsulation, | ||
changeDetection, | ||
}) | ||
export class TuiComboBoxExample7 { | ||
value = null; | ||
|
||
readonly items = [ | ||
{name: 'John', surname: 'Cleese', disabled: false}, | ||
{name: 'Eric', surname: 'Idle', disabled: false}, | ||
{name: 'Graham', surname: 'Chapman', disabled: true}, | ||
{name: 'Michael', surname: 'Palin', disabled: true}, | ||
{name: 'Terry', surname: 'Gilliam', disabled: false}, | ||
{name: 'Terry', surname: 'Jones', disabled: false}, | ||
]; | ||
|
||
readonly stringify = (item: {name: string; surname: string}): string => | ||
`${item.name} ${item.surname}`; | ||
} |
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