mirror of
https://github.com/datahub-project/datahub.git
synced 2025-12-26 17:37:33 +00:00
Create Tag Modal Issue: Clear the input value on press. (#6212)
This commit is contained in:
parent
333598fda2
commit
bd217f8a58
1
datahub-web-react/src/app/shared/constants.ts
Normal file
1
datahub-web-react/src/app/shared/constants.ts
Normal file
@ -0,0 +1 @@
|
||||
export const ENTER_KEY_CODE = 13;
|
||||
@ -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,
|
||||
@ -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}
|
||||
/>
|
||||
@ -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 (
|
||||
@ -453,6 +465,7 @@ export default function EditTagTermsModal({
|
||||
onClear={clearInput}
|
||||
onFocus={() => setIsFocusedOnInput(true)}
|
||||
onBlur={handleBlur}
|
||||
onInputKeyDown={handleKeyDown}
|
||||
dropdownStyle={isShowingGlossaryBrowser ? { display: 'none' } : {}}
|
||||
>
|
||||
{tagSearchOptions}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user