Skip to content

Commit

Permalink
fix: expand bug
Browse files Browse the repository at this point in the history
  • Loading branch information
danwag06 committed Nov 1, 2024
1 parent 66233d7 commit fadf621
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/components/TxHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export const TxHistory = (props: TxHistoryProps) => {
const [currentPage, setCurrentPage] = useState(1);
const itemsPerPage = 25;
const { gorillaPoolService, chromeStorageService } = useServiceContext();
const [expandedRows, setExpandedRows] = useState<Set<number>>(new Set());
const [expandedRows, setExpandedRows] = useState<Set<string>>(new Set());

const tagPriorityOrder: Tag[] = ['list', 'bsv21', 'bsv20', 'origin', 'lock', 'fund']; // The order of these tags will determine the order of the icons and which is prioritized

Expand Down Expand Up @@ -227,11 +227,11 @@ export const TxHistory = (props: TxHistoryProps) => {
});
};

const toggleRowExpansion = (idx: number) => {
const toggleRowExpansion = (uniqueId: string) => {
setExpandedRows((prev) => {
const newSet = new Set(prev);
if (newSet.has(idx)) newSet.delete(idx);
else newSet.add(idx);
if (newSet.has(uniqueId)) newSet.delete(uniqueId);
else newSet.add(uniqueId);
return newSet;
});
};
Expand Down Expand Up @@ -293,12 +293,13 @@ export const TxHistory = (props: TxHistoryProps) => {
{ id?: string; icon?: string; amount?: number },
][],
);
const isExpanded = expandedRows.has(t.idx);
const uniqueId = `${t.txid}-${t.idx}`;
const isExpanded = expandedRows.has(uniqueId);
return (
<RowWrapper key={t.idx}>
<RowWrapper key={uniqueId}>
<HistoryRow
theme={theme}
onClick={summaryEntries.length > 1 ? () => toggleRowExpansion(t.idx) : undefined}
onClick={summaryEntries.length > 1 ? () => toggleRowExpansion(uniqueId) : undefined}
style={{
display: 'flex',
alignItems: 'center',
Expand Down

0 comments on commit fadf621

Please sign in to comment.