Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Tag Modal Issue: Clear the input value on press. #6212

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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