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(InviteToAnswer): Optimising style and interaction
haitaoo151fe851d3fd
diff --git a/ui/src/components/TagSelector/index.tsx b/ui/src/components/TagSelector/index.tsxindex 9cdf1c60..51a712df 100644--- a/ui/src/components/TagSelector/index.tsx+++ b/ui/src/components/TagSelector/index.tsx@@ -110,6 +110,11 @@ const TagSelector: FC<IProps> = ({fetchTags(searchValue);}, [visibleMenu]);+ const resetSearch = () => {+ setCurrentIndex(0);+ setSearchValue('');+ setTags([]);+ };const handleClick = (val: Type.Tag) => {const findIndex = initialValue.findIndex((item) => item.slug_name.toLowerCase() === val.slug_name.toLowerCase(),@@ -130,6 +135,7 @@ const TagSelector: FC<IProps> = ({setRepeatIndex(-1);}, 2000);}+ resetSearch();};const handleRemove = (val: Type.Tag) => {@@ -178,9 +184,9 @@ const TagSelector: FC<IProps> = ({}if (currentIndex <= tags.length - 1) {handleClick(tags[currentIndex]);- if (currentIndex === tags.length - 1 && currentIndex > 0) {- setCurrentIndex(currentIndex - 1);- }+ // if (currentIndex === tags.length - 1 && currentIndex > 0) {+ // setCurrentIndex(currentIndex - 1);+ // }}}};diff --git a/ui/src/pages/Questions/Detail/components/InviteToAnswer/PeopleDropdown.scss b/ui/src/pages/Questions/Detail/components/InviteToAnswer/PeopleDropdown.scssindex 6ec2eaa1..92907656 100644--- a/ui/src/pages/Questions/Detail/components/InviteToAnswer/PeopleDropdown.scss+++ b/ui/src/pages/Questions/Detail/components/InviteToAnswer/PeopleDropdown.scss@@ -1,6 +1,6 @@.people-dropdown {.dropdown-menu {- min-width: 15rem;+ width: 15rem;}.dropdown-item.active {diff --git a/ui/src/pages/Questions/Detail/components/InviteToAnswer/PeopleDropdown.tsx b/ui/src/pages/Questions/Detail/components/InviteToAnswer/PeopleDropdown.tsxindex b4ed12a7..3b3a7911 100644--- a/ui/src/pages/Questions/Detail/components/InviteToAnswer/PeopleDropdown.tsx+++ b/ui/src/pages/Questions/Detail/components/InviteToAnswer/PeopleDropdown.tsx@@ -59,12 +59,10 @@ const Index: FC<Props> = ({searchPeople(s);};- const updateCurrentIndex = (pl: number) => {- let curIndex = currentIndex;- if (currentIndex >= pl) {- curIndex = Math.max(pl - 1, 0);- }- setCurrentIndex(curIndex);+ const resetSearch = () => {+ setCurrentIndex(0);+ setSearchValue('');+ setPeopleList([]);};const handleSelect = (idx) => {@@ -73,9 +71,10 @@ const Index: FC<Props> = ({}const people = peopleList[idx];if (people) {- updateCurrentIndex(peopleList.length - 1);onSelect(people);}++ resetSearch();};const handleKeyDown = (evt) => {@@ -115,7 +114,6 @@ const Index: FC<Props> = ({return visible ? (<DropdownclassName="d-inline-flex people-dropdown"- align="end"onSelect={handleSelect}onKeyDown={handleKeyDown}onToggle={setToggleState}>@@ -147,8 +145,12 @@ const Index: FC<Props> = ({className={idx === 0 ? 'mt-2' : ''}><div className="d-flex align-items-center text-nowrap"><Avatar avatar={p.avatar} size="24" className="rounded-1" />- <span className="mx-2">{p.display_name}</span>- <small className="text-secondary">@{p.username}</small>+ <div className="d-flex flex-wrap text-truncate">+ <span className="ms-2 text-truncate">{p.display_name}</span>+ <small className="text-secondary text-truncate ms-2">+ @{p.username}+ </small>+ </div></div></Dropdown.Item>);diff --git a/ui/src/pages/Questions/Detail/components/InviteToAnswer/index.tsx b/ui/src/pages/Questions/Detail/components/InviteToAnswer/index.tsxindex 9604b1c4..41f7eb48 100644--- a/ui/src/pages/Questions/Detail/components/InviteToAnswer/index.tsx+++ b/ui/src/pages/Questions/Detail/components/InviteToAnswer/index.tsx@@ -115,7 +115,11 @@ const Index: FC<Props> = ({ questionId, readOnly = false }) => {className="m-1 d-inline-flex flex-nowrap"size="sm"variant="outline-secondary">- <Avatar avatar={user.avatar} size="20" />+ <Avatar+ avatar={user.avatar}+ size="20"+ className="rounded-1"+ /><span className="text-nowrap ms-2">{user.display_name}</span>{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events */}<span