diff --git a/src/app/organisms/room/PeopleDrawer.jsx b/src/app/organisms/room/PeopleDrawer.jsx index dc58015..7cf9a59 100644 --- a/src/app/organisms/room/PeopleDrawer.jsx +++ b/src/app/organisms/room/PeopleDrawer.jsx @@ -1,4 +1,6 @@ -import React, { useState, useEffect, useCallback } from 'react'; +import React, { + useState, useEffect, useCallback, useRef, +} from 'react'; import PropTypes from 'prop-types'; import './PeopleDrawer.scss'; @@ -10,6 +12,7 @@ import AsyncSearch from '../../../util/AsyncSearch'; import Text from '../../atoms/text/Text'; import Header, { TitleWrapper } from '../../atoms/header/Header'; +import RawIcon from '../../atoms/system-icons/RawIcon'; import IconButton from '../../atoms/button/IconButton'; import Button from '../../atoms/button/Button'; import ScrollView from '../../atoms/scroll/ScrollView'; @@ -17,6 +20,8 @@ import Input from '../../atoms/input/Input'; import PeopleSelector from '../../molecules/people-selector/PeopleSelector'; import AddUserIC from '../../../../public/res/ic/outlined/add-user.svg'; +import SearchIC from '../../../../public/res/ic/outlined/search.svg'; +import CrossIC from '../../../../public/res/ic/outlined/cross.svg'; function AtoZ(m1, m2) { const aName = m1.name; @@ -61,6 +66,7 @@ function PeopleDrawer({ roomId }) { const [membership, setMembership] = useState('join'); const [memberList, setMemberList] = useState([]); const [searchedMembers, setSearchedMembers] = useState(null); + const searchRef = useRef(null); const getMembersWithMembership = useCallback( (mship) => room.getMembersWithMembership(mship), @@ -79,10 +85,13 @@ function PeopleDrawer({ roomId }) { } function handleSearch(e) { - if (e.target.value === '') { + const term = e.target.value; + if (term === '' || term === undefined) { + searchRef.current.value = ''; + searchRef.current.focus(); setSearchedMembers(null); setItemCount(PER_PAGE_MEMBER); - } else asyncSearch.search(e.target.value); + } else asyncSearch.search(term); } useEffect(() => { @@ -93,6 +102,7 @@ function PeopleDrawer({ roomId }) { }, [memberList]); useEffect(() => { + searchRef.current.value = ''; setMemberList( simplyfiMembers( getMembersWithMembership(membership) @@ -147,9 +157,20 @@ function PeopleDrawer({ roomId }) { /> )) } + { + searchedMembers?.data.length === 0 + && ( +
+ No result found! +
+ ) + }
{ - mList.length !== 0 && memberList.length > itemCount && ( + mList.length !== 0 + && memberList.length > itemCount + && searchedMembers === null + && ( ) } @@ -159,7 +180,12 @@ function PeopleDrawer({ roomId }) {
e.preventDefault()} className="people-search"> - + + + { + searchedMembers !== null + && + }
diff --git a/src/app/organisms/room/PeopleDrawer.scss b/src/app/organisms/room/PeopleDrawer.scss index b3a2182..85a4c12 100644 --- a/src/app/organisms/room/PeopleDrawer.scss +++ b/src/app/organisms/room/PeopleDrawer.scss @@ -35,6 +35,11 @@ @extend .people-drawer-flexItem; } + &__noresult { + padding: var(--sp-extra-tight) var(--sp-normal); + text-align: center; + } + &__sticky { & .people-search { --search-input-height: 40px; @@ -44,8 +49,33 @@ position: relative; bottom: var(--sp-normal); + display: flex; + align-items: center; + & > .ic-raw, + & > .ic-btn { + position: absolute; + z-index: 99; + } + & > .ic-raw { + left: var(--sp-tight); + [dir=rtl] & { + right: var(--sp-tight); + left: unset; + } + } + & > .ic-btn { + right: 2px; + [dir=rtl] & { + left: 2px; + right: unset; + } + } + & .input-container { + flex: 1; + } & .input { + padding: 0 calc(var(--sp-loose) + var(--sp-normal)); height: var(--search-input-height); } }