@@ -14,12 +14,14 @@ import { useSortable } from "../common/dnd/useSortable"
1414import { OverlayScrollbar } from "../common/overlay-scrollbar"
1515import type { ItemsProps } from "./card"
1616import { CardWrapper } from "./card"
17- import { currentSourcesAtom } from "~/atoms"
17+ import { currentColumnIDAtom , currentSourcesAtom } from "~/atoms"
1818
1919const AnimationDuration = 200
2020const WIDTH = 350
2121export function Dnd ( ) {
2222 const [ items , setItems ] = useAtom ( currentSourcesAtom )
23+ const currentColumnID = useAtomValue ( currentColumnIDAtom )
24+ const sortable = currentColumnID === "focus"
2325 const [ parent ] = useAutoAnimate ( { duration : AnimationDuration } )
2426 useEntireQuery ( items )
2527 const { width } = useWindowSize ( )
@@ -31,7 +33,7 @@ export function Dnd() {
3133 if ( ! items . length ) return null
3234
3335 return (
34- < DndWrapper items = { items } setItems = { setItems } isSingleColumn = { isMobile } >
36+ < DndWrapper items = { items } setItems = { setItems } isSingleColumn = { isMobile } sortable = { sortable } >
3537 < OverlayScrollbar defer className = "overflow-x-auto" >
3638 < motion . ol
3739 className = { isMobile
@@ -80,7 +82,7 @@ export function Dnd() {
8082 } ,
8183 } }
8284 >
83- < SortableCardWrapper id = { id } />
85+ < SortableCardWrapper id = { id } sortable = { sortable } />
8486 </ motion . li >
8587 ) ) }
8688 </ motion . ol >
@@ -94,10 +96,11 @@ export function Dnd() {
9496 )
9597}
9698
97- function DndWrapper ( { items, setItems, isSingleColumn, children } : PropsWithChildren < {
99+ function DndWrapper ( { items, setItems, isSingleColumn, sortable , children } : PropsWithChildren < {
98100 items : SourceID [ ]
99101 setItems : ( items : SourceID [ ] ) => void
100102 isSingleColumn : boolean
103+ sortable : boolean
101104} > ) {
102105 const onDropTargetChange = useCallback ( ( { location, source } : BaseEventPayload < ElementDragType > ) => {
103106 const traget = location . current . dropTargets [ 0 ]
@@ -122,6 +125,8 @@ function DndWrapper({ items, setItems, isSingleColumn, children }: PropsWithChil
122125 wait : AnimationDuration ,
123126 } )
124127 const { el } = useAtomValue ( goToTopAtom )
128+ if ( ! sortable ) return children
129+
125130 return (
126131 < DndContext onDropTargetChange = { run } autoscroll = { el ? { element : el } : undefined } >
127132 { children }
@@ -166,7 +171,7 @@ function CardOverlay({ id }: { id: SourceID }) {
166171 )
167172}
168173
169- function SortableCardWrapper ( { id } : ItemsProps ) {
174+ function SortableCardWrapper ( { id, sortable } : ItemsProps & { sortable : boolean } ) {
170175 const {
171176 isDragging,
172177 setNodeRef,
@@ -186,7 +191,7 @@ function SortableCardWrapper({ id }: ItemsProps) {
186191 ref = { setNodeRef }
187192 id = { id }
188193 isDragging = { isDragging }
189- setHandleRef = { setHandleRef }
194+ setHandleRef = { sortable ? setHandleRef : undefined }
190195 />
191196 { OverlayContainer && createPortal ( < CardOverlay id = { id } /> , OverlayContainer ) }
192197 </ >
0 commit comments