Skip to content

Commit

Permalink
fix: fixed behavior when the user could add new namespace to the list…
Browse files Browse the repository at this point in the history
… of namespaces
  • Loading branch information
EduardIvanov22 committed Dec 3, 2021
1 parent 7d90037 commit 7242a31
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/components/organisms/NewResourceWizard/NewResourceWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,8 @@ const NewResourceWizard = () => {
));
};

const onSelectChange = (value: string) => {
if (value.startsWith(NEW_ITEM)) {
setNamespaces([...namespaces, inputValue]);
form.setFieldsValue({namespace: inputValue});
}
const onSelectChange = () => {
setInputValue('');
};

useHotkeys(
Expand Down Expand Up @@ -298,14 +295,14 @@ const NewResourceWizard = () => {
>
<Select
showSearch
onSearch={(text: string) => {
onSearch={text => {
setInputValue(text);
}}
onChange={onSelectChange}
>
{inputValue && namespaces.every(namespace => namespace !== inputValue) ? (
<Option key={inputValue} value={`${NEW_ITEM} - ${inputValue}`}>
create {`"${inputValue}"`}
<Option key={inputValue} value={inputValue}>
{inputValue}
</Option>
) : null}
{namespaces.map(namespace => {
Expand Down

0 comments on commit 7242a31

Please sign in to comment.