From b6a46a4e117cd14bf61204d3878e66c776cab341 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Thu, 19 Jan 2023 00:52:53 -0500 Subject: [PATCH] controlled components --- .../explore/CategoryOptions.tsx | 22 ++++++++-------- .../explore/ExploreVoicesModal.tsx | 25 +++++++++---------- .../explore/LanguageOptions.tsx | 2 +- .../explore/ScopedVoiceModelOptions.tsx | 2 +- .../tts_model_list/search/SelectSearch.tsx | 8 ++---- 5 files changed, 28 insertions(+), 31 deletions(-) diff --git a/packages/fakeyou.com/src/v2/view/tts/tts_model_list/explore/CategoryOptions.tsx b/packages/fakeyou.com/src/v2/view/tts/tts_model_list/explore/CategoryOptions.tsx index e4c2422941..3ac233993e 100644 --- a/packages/fakeyou.com/src/v2/view/tts/tts_model_list/explore/CategoryOptions.tsx +++ b/packages/fakeyou.com/src/v2/view/tts/tts_model_list/explore/CategoryOptions.tsx @@ -166,18 +166,10 @@ export function CategoryOptions(props: Props) { let categoryDropdowns = buildDropdowns( dropdownCategories, + selectedCategories, ttsModelsByCategoryToken, handleChangeCategory); - const options = [ - { value: "chocolate", label: "Chocolate" }, - { value: "strawberry", label: "Strawberry" }, - { value: "vanilla", label: "Vanilla" }, - { value: "chocolate", label: "Chocolate" }, - { value: "strawberry", label: "Strawberry" }, - { value: "vanilla", label: "Vanilla" }, - ]; - const CATEGORY_SEPARATOR = (
>, handleChangeCategory : (i: number, categoryToken?: string) => void, ) { @@ -214,6 +207,7 @@ function buildDropdowns( for (let i = 0; i < dropdownCategories.length; i++) { const currentDropdownCategories = dropdownCategories[i]; + const selectedCategory = selectedCategories[i]; let defaultName = i === 0 ? "All Voices" : "Select..."; @@ -255,6 +249,14 @@ function buildDropdowns( ); }); + let selectedCategoryOption = undefined; + if (selectedCategory !== undefined) { + selectedCategoryOption = { + value: selectedCategory.category_token, + label: selectedCategory.name_for_dropdown, + }; + } + if (dropdownOptions.length <= 1) { // We've run out of subcategories. (1 == "Select...") // No sense trying to build more. @@ -269,7 +271,7 @@ function buildDropdowns( diff --git a/packages/fakeyou.com/src/v2/view/tts/tts_model_list/explore/ScopedVoiceModelOptions.tsx b/packages/fakeyou.com/src/v2/view/tts/tts_model_list/explore/ScopedVoiceModelOptions.tsx index 858081f280..d9a931d51b 100644 --- a/packages/fakeyou.com/src/v2/view/tts/tts_model_list/explore/ScopedVoiceModelOptions.tsx +++ b/packages/fakeyou.com/src/v2/view/tts/tts_model_list/explore/ScopedVoiceModelOptions.tsx @@ -98,7 +98,7 @@ export function ScopedVoiceModelOptions(props: Props) {