Skip to content

Commit

Permalink
perf: optimize group drag positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
moonrailgun committed Aug 11, 2023
1 parent 70151af commit 2adfe92
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions client/web/src/routes/Main/Navbar/GroupNav.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Avatar, Icon } from 'tailchat-design';
import { openModal } from '@/components/Modal';
import { ModalCreateGroup } from '@/components/modals/CreateGroup';
import React, { useMemo } from 'react';
import React, { useMemo, useRef } from 'react';
import {
GroupInfo,
showSuccessToasts,
Expand Down Expand Up @@ -101,6 +101,7 @@ function useGroupList() {
}

export const GroupNav: React.FC = React.memo(() => {
const containerRef = useRef<HTMLDivElement>(null);
const { groupList, handleSortEnd } = useGroupList();

const handleCreateGroup = useEvent(() => {
Expand All @@ -112,12 +113,16 @@ export const GroupNav: React.FC = React.memo(() => {
}));

return (
<div className="space-y-2" data-tc-role="navbar-groups">
<div className="space-y-2" data-tc-role="navbar-groups" ref={containerRef}>
{Array.isArray(groupList) && (
<SortableList className="space-y-2" onSortEnd={handleSortEnd}>
<SortableList
className="space-y-2"
onSortEnd={handleSortEnd}
customHolderRef={containerRef}
>
{groupList.map((group) => (
<SortableItem key={group._id}>
<div>
<div className="overflow-hidden">
<GroupNavItem group={group} />
</div>
</SortableItem>
Expand Down

0 comments on commit 2adfe92

Please sign in to comment.