A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
fix: #866, #951
robina5569959fcfb
diff --git a/ui/src/components/TagSelector/index.tsx b/ui/src/components/TagSelector/index.tsxindex b64336a7..c8edc47f 100644--- a/ui/src/components/TagSelector/index.tsx+++ b/ui/src/components/TagSelector/index.tsx@@ -38,6 +38,8 @@ const TagSelector: FC<IProps> = ({const [tag, setTag] = useState<string>('');const [tags, setTags] = useState<Type.Tag[] | null>(null);const { t } = useTranslation('translation', { keyPrefix: 'tag_selector' });+ const [visibleMenu, setVisibleMenu] = useState(false);+const tagModal = useTagModal({onConfirm: (data) => {if (!(onChange instanceof Function)) {@@ -150,9 +152,34 @@ const TagSelector: FC<IProps> = ({const handleSelect = (eventKey) => {setCurrentIndex(eventKey);};+ const handleKeyDown = (e) => {+ e.stopPropagation();+ if (!tags) {+ return;+ }+ const { keyCode } = e;+ if (keyCode === 38 && currentIndex > 0) {+ setCurrentIndex(currentIndex - 1);+ }+ if (keyCode === 40 && currentIndex < tags.length - 1) {+ setCurrentIndex(currentIndex + 1);+ }+ if (+ keyCode === 13 &&+ currentIndex > -1 &&+ currentIndex <= tags.length - 1+ ) {+ e.preventDefault();+ handleClick(tags[currentIndex]);+ }+ };return (- <div className="tag-selector-wrap" onFocus={onFocus} onBlur={onBlur}>+ <div+ className="tag-selector-wrap"+ onFocus={onFocus}+ onBlur={onBlur}+ onKeyDown={handleKeyDown}><div className="d-flex flex-wrap">{initialValue?.map((item, index) => {return (@@ -173,20 +200,28 @@ const TagSelector: FC<IProps> = ({);})}{initialValue?.length < 5 || alwaysShowAddBtn ? (- <Dropdown onSelect={handleSelect}>+ <Dropdown onSelect={handleSelect} onToggle={setVisibleMenu}><Dropdown.Toggle variant="outline-secondary" size="sm"><span className="me-1">+</span>{t('add_btn')}</Dropdown.Toggle><Dropdown.Menu>- <Dropdown.Header>- <FormControl- placeholder="Search tag"- autoFocus- value={tag}- onChange={handleSearch}- />- </Dropdown.Header>+ {visibleMenu && (+ <Dropdown.Header>+ <Form+ onSubmit={(e) => {+ e.preventDefault();+ }}>+ <FormControl+ placeholder={t('search_tag')}+ autoFocus+ value={tag}+ onChange={handleSearch}+ />+ </Form>+ </Dropdown.Header>+ )}+{tags?.map((item, index) => {return (<Dropdown.Itemdiff --git a/ui/src/i18n/locales/en.json b/ui/src/i18n/locales/en.jsonindex 8f190e6d..eaca6094 100644--- a/ui/src/i18n/locales/en.json+++ b/ui/src/i18n/locales/en.json@@ -408,6 +408,7 @@"tag_selector": {"add_btn": "Add tag","create_btn": "Create new tag",+ "search_tag": "Search tag","hint": "Describe what your question is about, at least one tag is required.","no_result": "No tags matched"},@@ -863,4 +864,4 @@}}}-}+}\ No newline at end of file