diff --git a/ui/src/components/TagSelector/index.scss b/ui/src/components/TagSelector/index.scss index 1a53ac42..5d26102e 100644 --- a/ui/src/components/TagSelector/index.scss +++ b/ui/src/components/TagSelector/index.scss @@ -61,6 +61,14 @@ white-space: nowrap; } + .a-placeholder-width { + display: inline-block; + position: absolute; + height: 0; + overflow: hidden; + max-width: calc(100% - 40px); + } + } .tag-selector-wrap--focus { diff --git a/ui/src/components/TagSelector/index.tsx b/ui/src/components/TagSelector/index.tsx index 25ec293d..6b10c236 100644 --- a/ui/src/components/TagSelector/index.tsx +++ b/ui/src/components/TagSelector/index.tsx @@ -328,13 +328,19 @@ const TagSelector: FC = ({ useEffect(() => { // set width of tag Form.Control const ele = document.querySelector('.a-input-width') as HTMLElement; + const elePlaceholder = document.querySelector( + '.a-placeholder-width', + ) as HTMLElement; if (ele.offsetWidth > 60) { inputRef.current?.setAttribute( 'style', `width:${ele.offsetWidth + 16}px`, ); } else { - inputRef.current?.setAttribute('style', 'width: 60px'); + inputRef.current?.setAttribute( + 'style', + `width: ${elePlaceholder.offsetWidth + 7}px`, + ); } }, [searchValue]); @@ -392,6 +398,7 @@ const TagSelector: FC = ({ /> )} {searchValue} + {t('add_btn')} diff --git a/ui/src/pages/Review/components/EditPostModal/index.tsx b/ui/src/pages/Review/components/EditPostModal/index.tsx index 9e7ae5e9..5a4529fd 100644 --- a/ui/src/pages/Review/components/EditPostModal/index.tsx +++ b/ui/src/pages/Review/components/EditPostModal/index.tsx @@ -346,11 +346,6 @@ const Index: FC = ({ {objectType === 'question' && ( {t('form.fields.tags.label')} - )}