Skip to content
This repository was archived by the owner on Feb 12, 2026. It is now read-only.

Commit b74e647

Browse files
committed
fix: use the common DragHandle component everywhere
1 parent c1ef8fb commit b74e647

5 files changed

Lines changed: 40 additions & 49 deletions

File tree

src/components/client/InstructionHeader.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import {
22
ChevronDownIcon,
33
ChevronRightIcon,
44
DeleteIcon,
5-
DragHandleIcon,
65
} from "@chakra-ui/icons";
76
import {
87
Flex,
@@ -16,7 +15,7 @@ import {
1615
Tooltip,
1716
} from "@chakra-ui/react";
1817
import { arrayMove } from "@dnd-kit/sortable";
19-
import React, { useContext } from "react";
18+
import React from "react";
2019
import {
2120
FaAngleDoubleDown,
2221
FaAngleDoubleUp,
@@ -28,13 +27,12 @@ import {
2827
import { useInstruction } from "../../hooks/useInstruction";
2928
import { useSessionStoreWithUndo } from "../../hooks/useSessionStore";
3029
import { removeFrom } from "../../utils/sortable";
30+
import { DragHandle } from "../common/DragHandle";
3131
import { EditableName } from "../common/EditableName";
3232
import { Numbering } from "../common/Numbering";
33-
import { SortableItemContext } from "../common/Sortable";
3433

3534
export const InstructionHeader: React.FC<{ index: number }> = ({ index }) => {
3635
const { instruction, update, reset } = useInstruction();
37-
const { listeners, attributes } = useContext(SortableItemContext);
3836

3937
const [instructionOrder, set] = useSessionStoreWithUndo((state) => [
4038
state.transaction.instructions.order,
@@ -43,7 +41,7 @@ export const InstructionHeader: React.FC<{ index: number }> = ({ index }) => {
4341

4442
return (
4543
<Flex mb={instruction.expanded ? "4" : undefined} alignItems="center">
46-
<DragHandleIcon mr="2" {...attributes} {...listeners} />
44+
<DragHandle unlockedProps={{ mr: "2" }} />
4745

4846
<IconButton
4947
h="8"

src/components/client/accounts/PdaButton.tsx

Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
import {
2-
AddIcon,
3-
CloseIcon,
4-
DragHandleIcon,
5-
SearchIcon,
6-
} from "@chakra-ui/icons";
1+
import { AddIcon, CloseIcon, SearchIcon } from "@chakra-ui/icons";
72
import {
83
Box,
94
Button,
@@ -29,7 +24,7 @@ import {
2924
} from "@chakra-ui/react";
3025
import { PublicKey } from "@solana/web3.js";
3126
import produce, { Draft } from "immer";
32-
import React, { useContext, useRef, useState } from "react";
27+
import React, { useRef, useState } from "react";
3328
import { FaRobot } from "react-icons/fa";
3429
import { v4 as uuid } from "uuid";
3530
import { IPubKey } from "../../../types/internal";
@@ -40,7 +35,8 @@ import {
4035
toSortableCollection,
4136
toSortedArray,
4237
} from "../../../utils/sortable";
43-
import { Sortable, SortableItemContext } from "../../common/Sortable";
38+
import { DragHandle } from "../../common/DragHandle";
39+
import { Sortable } from "../../common/Sortable";
4440

4541
type Seed = { value: string } & Identifiable;
4642
type SeedState = SortableCollection<Seed>;
@@ -190,34 +186,32 @@ const SeedItem = forwardRef<
190186
removeSeed: () => void;
191187
},
192188
"div"
193-
>(({ seed, setSeed, removeSeed }, ref) => {
194-
const { listeners, attributes } = useContext(SortableItemContext);
189+
>(({ seed, setSeed, removeSeed }, ref) => (
190+
<Flex alignItems="center" mb="1">
191+
<DragHandle unlockedProps={{ h: "2.5", w: "2.5", mr: "1" }} />
195192

196-
return (
197-
<Flex alignItems="center" mb="1">
198-
<DragHandleIcon h="2.5" w="2.5" mr="1" {...attributes} {...listeners} />
199-
<Input
200-
ref={ref}
201-
placeholder="Seed"
202-
size="sm"
203-
value={seed.value}
204-
key={seed.id}
205-
onChange={(e) => {
206-
setSeed((state) => {
207-
state.value = e.target.value;
208-
});
209-
}}
193+
<Input
194+
ref={ref}
195+
placeholder="Seed"
196+
size="sm"
197+
value={seed.value}
198+
key={seed.id}
199+
onChange={(e) => {
200+
setSeed((state) => {
201+
state.value = e.target.value;
202+
});
203+
}}
204+
/>
205+
206+
<Tooltip label="Remove">
207+
<IconButton
208+
ml="1"
209+
size="xs"
210+
aria-label="Remove"
211+
icon={<CloseIcon />}
212+
variant="ghost"
213+
onClick={removeSeed}
210214
/>
211-
<Tooltip label="Remove">
212-
<IconButton
213-
ml="1"
214-
size="xs"
215-
aria-label="Remove"
216-
icon={<CloseIcon />}
217-
variant="ghost"
218-
onClick={removeSeed}
219-
/>
220-
</Tooltip>
221-
</Flex>
222-
);
223-
});
215+
</Tooltip>
216+
</Flex>
217+
));

src/components/options/fields/RpcEndpointOption.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DeleteIcon, DragHandleIcon } from "@chakra-ui/icons";
1+
import { DeleteIcon } from "@chakra-ui/icons";
22
import {
33
Flex,
44
Grid,
@@ -9,12 +9,12 @@ import {
99
Tooltip,
1010
} from "@chakra-ui/react";
1111
import { WritableDraft } from "immer/dist/internal";
12-
import React, { useContext, useState } from "react";
12+
import React, { useState } from "react";
1313
import { FaEye, FaEyeSlash } from "react-icons/fa";
1414
import { usePersistentStore } from "../../../hooks/usePersistentStore";
1515
import { INetwork, IRpcEndpoint } from "../../../types/internal";
1616
import { removeFrom } from "../../../utils/sortable";
17-
import { SortableItemContext } from "../../common/Sortable";
17+
import { DragHandle } from "../../common/DragHandle";
1818

1919
const isValidUrl = (url: string) => {
2020
try {
@@ -33,7 +33,6 @@ export const RpcEndpointOption: React.FC<IRpcEndpoint> = ({
3333
custom,
3434
enabled,
3535
}) => {
36-
const { listeners, attributes } = useContext(SortableItemContext);
3736
const set = usePersistentStore((state) => state.set);
3837

3938
const updateEndpoint = (fn: (state: WritableDraft<IRpcEndpoint>) => void) => {
@@ -53,7 +52,7 @@ export const RpcEndpointOption: React.FC<IRpcEndpoint> = ({
5352

5453
return (
5554
<Flex alignItems="center">
56-
<DragHandleIcon h="3" w="3" mr="1" {...attributes} {...listeners} />
55+
<DragHandle unlockedProps={{ h: "3", w: "3", mr: "1" }} />
5756

5857
<Grid
5958
p="4"

src/components/palette/preview/InstructionPreview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const InstructionPreview: React.FC<{
4343
>
4444
<Flex mb="1" alignItems="center">
4545
{/* TODO implement drag-and-drop */}
46-
{/* <DragHandleIcon h="2.5" mr="1" /> */}
46+
{/* <DragHandle unlockedProps={{ h: "2.5", mr: "1" }} /> */}
4747

4848
<InstructionIcon />
4949

src/components/palette/preview/Preview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export const Preview: React.FC<{
6060
>
6161
<Flex mb="3" alignItems="center">
6262
{/* TODO implement drag-and-drop */}
63-
{/* <DragHandleIcon h="2.5" mt="1" mr="1" /> */}
63+
{/* <DragHandle unlockedProps={{ h: "2.5", mt: "1", mr: "1" }} /> */}
6464

6565
{/* icon */}
6666
{isSource("anchorProgramId", "anchorJson") && <AnchorIcon />}

0 commit comments

Comments
 (0)