Skip to content

Commit 4239291

Browse files
authored
fix(web-components): Dropdown opens and immediately closes on space key interaction (#33767)
1 parent f706fe1 commit 4239291

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "fix: dropdown opens then closes on space key",
4+
"packageName": "@fluentui/web-components",
5+
"email": "863023+radium-v@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}

packages/web-components/src/dropdown/dropdown.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ test.describe('Dropdown', () => {
7272
await expect(listbox).toBeHidden();
7373
});
7474

75+
test('should open the dropdown when the space key is pressed', async ({ fastPage }) => {
76+
const { element } = fastPage;
77+
const listbox = element.locator('fluent-listbox');
78+
const button = element.locator('[role=combobox]');
79+
80+
await button.press(' ');
81+
82+
await expect(listbox).toBeVisible();
83+
});
84+
7585
test("should set the `name` property on options when it's set on the dropdown", async ({ fastPage }) => {
7686
const { element } = fastPage;
7787
const options = element.locator('fluent-option');

packages/web-components/src/dropdown/dropdown.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,8 @@ export class BaseDropdown extends FASTElement {
725725
if (this.isCombobox) {
726726
break;
727727
}
728+
729+
e.preventDefault();
728730
}
729731

730732
case 'Enter':

0 commit comments

Comments
 (0)