Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix(settings): filter Autocomplete items when typing in settingsdropdown (#683)

Neha Prasad06c418cc8f27
diff --git a/__tests__/components/features/settings/settings-dropdown-input.test.tsx b/__tests__/components/features/settings/settings-dropdown-input.test.tsx
index 710358cac1..69f38a3040 100644
--- a/__tests__/components/features/settings/settings-dropdown-input.test.tsx
+++ b/__tests__/components/features/settings/settings-dropdown-input.test.tsx
@@ -41,6 +41,29 @@ describe("SettingsDropdownInput", () => {
expect(onSelectionChange).toHaveBeenCalledWith("spanish");
});
+ it("filters options while typing", async () => {
+ const user = userEvent.setup();
+
+ render(
+ <SettingsDropdownInput
+ defaultSelectedKey="english"
+ items={items}
+ label="Language"
+ name="language"
+ testId="language-input"
+ />,
+ );
+
+ const input = screen.getByLabelText("Language");
+ await user.click(input);
+ await user.clear(input);
+ await user.keyboard("Germ");
+
+ expect(await screen.findByText("German")).toBeInTheDocument();
+ expect(screen.queryByText("English")).not.toBeInTheDocument();
+ expect(screen.queryByText("Spanish")).not.toBeInTheDocument();
+ });
+
it("clears the selection when the clear button is pressed", async () => {
const user = userEvent.setup();
const onSelectionChange = vi.fn();
diff --git a/src/components/features/settings/settings-dropdown-input.tsx b/src/components/features/settings/settings-dropdown-input.tsx
index 67420fc6eb..107c26fd90 100644
--- a/src/components/features/settings/settings-dropdown-input.tsx
+++ b/src/components/features/settings/settings-dropdown-input.tsx
@@ -65,7 +65,7 @@ export function SettingsDropdownInput({
aria-label={typeof label === "string" ? label : name}
data-testid={testId}
name={name}
- items={items}
+ defaultItems={items}
defaultSelectedKey={defaultSelectedKey}
selectedKey={selectedKey}
onSelectionChange={onSelectionChange}