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")} className={$("btn", isFocused ? "i-ph:star-fill" : "i-ph:star-duotone")}
onClick={toggleFocus} onClick={toggleFocus}
/> />
{/* firefox cannot drag a button */}
{setHandleRef && ( {setHandleRef && (
<button <div
ref={setHandleRef} ref={setHandleRef}
type="button"
className={$("btn", "i-ph:dots-six-vertical-duotone", "cursor-grab")} className={$("btn", "i-ph:dots-six-vertical-duotone", "cursor-grab")}
/> />
)} )}

View File

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