diff --git a/projects/core/directives/dropdown/dropdown-selection.directive.ts b/projects/core/directives/dropdown/dropdown-selection.directive.ts index 069618d3c875..a9ecc4e47894 100644 --- a/projects/core/directives/dropdown/dropdown-selection.directive.ts +++ b/projects/core/directives/dropdown/dropdown-selection.directive.ts @@ -56,7 +56,10 @@ export class TuiDropdownSelectionDirective this.selection$.pipe( map(() => this.getRange()), distinctUntilChanged( - (x, y) => x.startOffset === y.startOffset && x.endOffset === y.endOffset, + (x, y) => + x.startOffset === y.startOffset && + x.endOffset === y.endOffset && + x.commonAncestorContainer === y.commonAncestorContainer, ), ), ]).pipe( diff --git a/projects/demo-playwright/tests/core/dropdown/dropdown.spec.ts b/projects/demo-playwright/tests/core/dropdown/dropdown.spec.ts index 190d895e2242..e157c6d3c2f5 100644 --- a/projects/demo-playwright/tests/core/dropdown/dropdown.spec.ts +++ b/projects/demo-playwright/tests/core/dropdown/dropdown.spec.ts @@ -79,4 +79,18 @@ test.describe('Dropdown', () => { await page.locator('tui-dropdown').locator('tui-scrollbar .t-thumb').click(); await expect(page).toHaveScreenshot('11-dropdown.png'); }); + + test('Dropdown selection', async ({page}) => { + await tuiGoto(page, '/directives/dropdown-selection'); + + const textarea = new TuiDocumentationPagePO(page) + .getExample('#textarea') + .locator('textarea'); + + await textarea.clear(); + await textarea.press('@'); + await textarea.press('Backspace'); + + await expect(page.locator('tui-dropdown')).not.toBeVisible(); + }); });