Skip to content

Commit 566384d

Browse files
🐛 apply validation to form labels before added as new option (guacsec#540)
Signed-off-by: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com>
1 parent 371e57d commit 566384d

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

client/src/app/components/Autocomplete/Autocomplete.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export const Autocomplete: React.FC<IAutocompleteProps> = ({
7676
optionsNotSelected,
7777
removeSelectionById,
7878
handleOnSelect,
79+
handleOnCreateNewOption,
7980
handleInputChange,
8081
handleKeyDown,
8182
handleClearSearchInput,
@@ -150,10 +151,7 @@ export const Autocomplete: React.FC<IAutocompleteProps> = ({
150151
<SelectOption
151152
id={createItemId("new-option")}
152153
isFocused={true}
153-
onClick={() => {
154-
const newOption = onCreateNewOption(inputValue);
155-
handleOnSelect(newOption);
156-
}}
154+
onClick={() => handleOnCreateNewOption(inputValue)}
157155
>{`Create new option "${inputValue}"`}</SelectOption>
158156
) : noResultsMessage && optionsNotSelected.length === 0 ? (
159157
<SelectOption isAriaDisabled>{noResultsMessage}</SelectOption>

client/src/app/components/Autocomplete/useAutocompleteHandlers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ export const useAutocompleteHandlers = ({
176176
handleInputChange,
177177
handleKeyDown,
178178
handleOnSelect,
179+
handleOnCreateNewOption,
179180
menuRef,
180181
searchInputRef,
181182
removeSelectionById,

0 commit comments

Comments
 (0)