Skip to content

Commit

Permalink
Create Tag Modal Issue: Clear the input value on press. (datahub-proj…
Browse files Browse the repository at this point in the history
  • Loading branch information
Ankit-Keshari-Vituity authored and cccs-tom committed Nov 18, 2022
1 parent 2a05b21 commit 3596af8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions datahub-web-react/src/app/shared/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const ENTER_KEY_CODE = 13;
15 changes: 14 additions & 1 deletion datahub-web-react/src/app/shared/tags/AddTagsTermsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { useEntityRegistry } from '../../useEntityRegistry';
import { useGetRecommendations } from '../recommendation';
import { FORBIDDEN_URN_CHARS_REGEX } from '../../entity/shared/utils';
import { TagTermLabel } from './TagTermLabel';
import { ENTER_KEY_CODE } from '../constants';

export enum OperationType {
ADD,
Expand Down Expand Up @@ -192,12 +193,17 @@ export default function EditTagTermsModal({
querySelectorToExecuteClick: '#addTagButton',
});

function handleOnClickBack() {
setInputValue('');
setShowCreateModal(false);
}

if (showCreateModal) {
return (
<CreateTagModal
visible={visible}
onClose={onCloseModal}
onBack={() => setShowCreateModal(false)}
onBack={handleOnClickBack}
tagName={inputValue}
resources={resources}
/>
Expand Down Expand Up @@ -406,6 +412,12 @@ export default function EditTagTermsModal({
setInputValue('');
}

function handleKeyDown(event) {
if (event.keyCode === ENTER_KEY_CODE) {
(inputEl.current as any).blur();
}
}

const isShowingGlossaryBrowser = !inputValue && type === EntityType.GlossaryTerm && isFocusedOnInput;

return (
Expand Down Expand Up @@ -453,6 +465,7 @@ export default function EditTagTermsModal({
onClear={clearInput}
onFocus={() => setIsFocusedOnInput(true)}
onBlur={handleBlur}
onInputKeyDown={handleKeyDown}
dropdownStyle={isShowingGlossaryBrowser ? { display: 'none' } : {}}
>
{tagSearchOptions}
Expand Down

0 comments on commit 3596af8

Please sign in to comment.