Allow reselecting the original option in gr.Dropdown after value has changed programmatically (#6517)

* fix

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
Abubakar Abid 2023-11-21 10:58:07 -08:00 committed by GitHub
parent c59b87d7b5
commit 901f3eebda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 0 deletions

View File

@ -0,0 +1,6 @@
---
"@gradio/dropdown": minor
"gradio": minor
---
feat:Allow reselecting the original option in `gr.Dropdown` after value has changed programmatically

View File

@ -364,5 +364,10 @@ describe("Dropdown", () => {
expect(item.value).toBe("");
options = getAllByTestId("dropdown-option");
expect(options[0]).not.toHaveClass("selected");
await component.$set({ value: "zebra" });
expect(item.value).toBe("zebra");
options = getAllByTestId("dropdown-option");
expect(options[0]).toHaveClass("selected");
});
});

View File

@ -116,6 +116,7 @@
input_text = "";
selected_index = null;
}
old_selected_index = selected_index;
}
function handle_option_selected(e: any): void {