Skip to content

Commit 499b8c8

Browse files
authored
Merge pull request #383 from 10up/fix/367
fix/367: Repeater: WordPress 6.8 Dragging issue
2 parents 3c0e147 + 40bde82 commit 499b8c8

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

components/drag-handle/index.tsx

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
1-
import type { SVGProps } from 'react';
1+
import type { HTMLAttributes } from 'react';
2+
3+
interface DragHandleProps extends HTMLAttributes<HTMLSpanElement> {
4+
isDragging?: boolean;
5+
}
26

37
/**
48
* Renders an SVG drag handle.
59
*
610
* @param {object} props The prop object.
711
* @returns {*} React JSX
812
*/
9-
10-
export const DragHandle: React.FC<SVGProps<SVGSVGElement>> = (props) => (
11-
<svg
12-
style={{ marginRight: '10px', cursor: 'grab', flexShrink: 0 }}
13-
width="18"
14-
height="18"
15-
xmlns="http://www.w3.org/2000/svg"
16-
viewBox="0 0 18 18"
17-
role="img"
18-
aria-hidden="true"
19-
focusable="false"
20-
{...props}
21-
>
22-
<path d="M5 4h2V2H5v2zm6-2v2h2V2h-2zm-6 8h2V8H5v2zm6 0h2V8h-2v2zm-6 6h2v-2H5v2zm6 0h2v-2h-2v2z" />
23-
</svg>
13+
export const DragHandle: React.FC<DragHandleProps> = (props) => (
14+
<span {...props} style={{ cursor: props.isDragging ? 'grabbing' : 'grab' }}>
15+
<svg
16+
style={{ marginRight: '10px', cursor: 'grab', flexShrink: 0 }}
17+
width="18"
18+
height="18"
19+
xmlns="http://www.w3.org/2000/svg"
20+
viewBox="0 0 18 18"
21+
role="img"
22+
aria-hidden="true"
23+
focusable="false"
24+
>
25+
<path d="M5 4h2V2H5v2zm6-2v2h2V2h-2zm-6 8h2V8H5v2zm6 0h2V8h-2v2zm-6 6h2v-2H5v2zm6 0h2v-2h-2v2z" />
26+
</svg>
27+
</span>
2428
);

components/repeater/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const SortableItem = ({ children, item = {}, setItem = null, removeItem = null,
6666
: repeaterItem.props.className,
6767
},
6868
[
69-
<DragHandle className="repeater-item__drag-handle" {...attributes} {...listeners} />,
69+
<DragHandle className="repeater-item__drag-handle" {...attributes} {...listeners} isDragging={ isDragging } />,
7070
repeaterItem.props.children,
7171
],
7272
);

0 commit comments

Comments
 (0)