fix: cannot dnd in firefox

This commit is contained in:
Ou 2024-11-22 01:08:49 +08:00
parent bf07610c43
commit 5af24c88d6
2 changed files with 4 additions and 6 deletions

View File

@ -140,10 +140,10 @@ function NewsCard({ id, setHandleRef }: NewsCardProps) {
className={$("btn", isFocused ? "i-ph:star-fill" : "i-ph:star-duotone")}
onClick={toggleFocus}
/>
{/* firefox cannot drag a button */}
{setHandleRef && (
<button
<div
ref={setHandleRef}
type="button"
className={$("btn", "i-ph:dots-six-vertical-duotone", "cursor-grab")}
/>
)}

View File

@ -37,10 +37,8 @@ export function useSortable(props: SortableProps) {
if (handleRef && nodeRef) {
const cleanup = combine(
draggable({
// use custom drag preview
element: handleRef,
// element: ref,
// dragHandle: handleRef,
element: nodeRef,
dragHandle: handleRef,
getInitialData: () => ({ id: props.id, instanceId }),
onGenerateDragPreview({ nativeSetDragImage, location }) {
setCustomNativeDragPreview({