Skip to content

Commit 59e20f0

Browse files
committed
Select option before accepting it
In the new version of Floating UI, it corrects that the JSDOM click was seen as a "mobile" click. Since [`focusItemOnOpen`](https://floating-ui.com/docs/useListNavigation#focusitemonopen) is set to `auto`, this results in selecting the first option when the suggest box was opened. Now that JSDOM is correctly detected as a keyboard input device, it will not select the first option when the suggest box is opened. The tests have been updated to account for this by always first selecting the first option before accepting it.
1 parent 11e5db9 commit 59e20f0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

extensions/ql-vscode/src/view/common/SuggestBox/__tests__/SuggestBox.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ describe("SuggestBox", () => {
167167
});
168168

169169
await userEvent.click(screen.getByRole("combobox"));
170-
await userEvent.keyboard("{Enter}");
170+
await userEvent.keyboard("{ArrowDown}{Enter}");
171171

172172
expect(onChange).toHaveBeenCalledWith("Argument[block].Parameter[1]");
173173
});
@@ -204,7 +204,7 @@ describe("SuggestBox", () => {
204204

205205
expect(screen.getAllByRole("option")).not.toHaveLength(0);
206206

207-
await userEvent.keyboard("{Enter}");
207+
await userEvent.keyboard("{ArrowDown}{Enter}");
208208

209209
expect(screen.queryByRole("option")).not.toBeInTheDocument();
210210
});
@@ -244,7 +244,7 @@ describe("SuggestBox", () => {
244244

245245
await userEvent.click(screen.getByRole("combobox"));
246246
await userEvent.keyboard(
247-
"{ArrowDown}{ArrowDown}{ArrowUp}{ArrowDown}{ArrowDown}{Enter}",
247+
"{ArrowDown}{ArrowDown}{ArrowDown}{ArrowUp}{ArrowDown}{ArrowDown}{Enter}",
248248
);
249249

250250
expect(onChange).toHaveBeenCalledWith("Argument[text_rep:]");
@@ -283,7 +283,7 @@ describe("SuggestBox", () => {
283283
});
284284

285285
await userEvent.click(screen.getByRole("combobox"));
286-
await userEvent.keyboard("{Enter}");
286+
await userEvent.keyboard("{ArrowDown}{Enter}");
287287

288288
expect(screen.queryByRole("option")).not.toBeInTheDocument();
289289

0 commit comments

Comments
 (0)