Releases: clauderic/dnd-kit
@dnd-kit/[email protected]
Patch Changes
-
#509
1c6369e
Thanks @clauderic! - Helpers have been updated to support rendering in foreignwindow
contexts (viaReactDOM.render
orReactDOM.createPortal
).For example, checking if an element is an instance of an
HTMLElement
is normally done like so:if (element instanceof HTMLElement)
However, when rendering in a different window, this can return false even if the element is indeed an HTMLElement, because this code is equivalent to:
if (element instanceof window.HTMLElement)
And in this case, the
window
of theelement
is different from the main execution contextwindow
, because we are rendering via a portal into another window.This can be solved by finding the local window of the element:
const elementWindow = element.ownerDocument.defaultView; if (element instanceof elementWindow.HTMLElement)
-
Updated dependencies [
1c6369e
]:- @dnd-kit/[email protected]
@dnd-kit/[email protected]
Minor Changes
-
#486
d86529c
Thanks @clauderic! - Improvements to better support swappable strategies:- Now exporting an
arraySwap
helper to be used instead ofarrayMove
onDragEnd
. - Added the
getNewIndex
prop onuseSortable
. By default,useSortable
assumes that items will be moved to their new index usingarrayMove()
, but this isn't always the case, especially when using strategies likerectSwappingStrategy
. For those scenarios, consumers can now define custom logic that should be used to get the new index for an item on drop, for example, by computing the new order of items usingarraySwap
.
- Now exporting an
Patch Changes
- Updated dependencies [
d973cc6
]:- @dnd-kit/[email protected]
@dnd-kit/[email protected]
Patch Changes
- #504
d973cc6
Thanks @clauderic! - Sensors that extend theAbstractPointerSensor
now prevent HTML Drag and Drop API events from being triggered while the sensor is activated.
@dnd-kit/[email protected]
@dnd-kit/[email protected]
Major Changes
- #373
1f5ca27
Thanks @clauderic! - Added react to peerDependencies of @dnd-kit/utilities
Minor Changes
- #334
13be602
Thanks @trentmwillis! - MoveCoordinates
interface along withgetEventCoordinates
,isMouseEvent
andisTouchEvent
helpers to @dnd-kit/utilities
Patch Changes
@dnd-kit/[email protected]
Major Changes
-
#427
f96cb5d
Thanks @clauderic! - - Using transform-agnostic measurements for the DragOverlay node.- Renamed the
overlayNode
property todragOverlay
on theDndContextDescriptor
interface.
- Renamed the
-
9cfac05
Thanks @clauderic! - Renamed thewasSorting
property towasDragging
on theSortableContext
andAnimateLayoutChanges
interfaces.
Minor Changes
- #433
c447880
Thanks @clauderic! - Fix unwanted animations when items in sortable context change
Patch Changes
-
#372
dbc9601
Thanks @clauderic! - RefactoredDroppableContainers
type fromRecord<UniqueIdentifier, DroppableContainer
to a custom instance that extends theMap
constructor and adds a few other methods such astoArray()
,getEnabled()
andgetNodeFor(id)
.A unique
key
property was also added to theDraggableNode
andDroppableContainer
interfaces. This prevents potential race conditions in the mount and cleanup effects ofuseDraggable
anduseDroppable
. It's possible for the clean-up effect to run after another React component usinguseDraggable
oruseDroppable
mounts, which causes the newly mounted element to accidentally be un-registered. -
#350
a13dbb6
Thanks @wmain! - Breaking change: TheCollisionDetection
interface has been refactored. It now receives an object that contains theactive
draggable node, along with thecollisionRect
and an array ofdroppableContainers
.If you've built custom collision detection algorithms, you'll need to update them. Refer to this PR for examples of how to refactor collision detection functions to the new
CollisionDetection
interface.The
sortableKeyboardCoordinates
method has also been updated since it relies on theclosestCorners
collision detection algorithm. If you were using collision detection strategies in a customsortableKeyboardCoordinates
method, you'll need to update those as well. -
86d1f27
Thanks @clauderic! - Fixed a bug in thehorizontalListSortingStrategy
where it did not check if thecurrentRect
was undefined. -
e42a711
Thanks @clauderic! - Fixed a bug with the default layout animation function where it could returntrue
initially even if the list had not been sorted yet. Now checking thewasDragging
property to ensure no layout animation occurs ifwasDragging
is false. -
#341
e02b737
Thanks @clauderic! - Returnundefined
instead ofnull
fortransition
inuseSortable
-
Updated dependencies [
13be602
,aede2cc
,05d6a78
,a32a4c5
,f96cb5d
,dea715c
,dbc9601
,46ec5e4
,7006464
,0e628bc
,c447880
,2ba6dfe
,8d70540
,13be602
,422d083
,c4b21b4
,5a41340
,a13dbb6
,e2ee0dc
,1fe9b5c
,1fe9b5c
,1f5ca27
]:- @dnd-kit/[email protected]
- @dnd-kit/[email protected]
@dnd-kit/[email protected]
Minor Changes
- #334
13be602
Thanks @trentmwillis! - AddsnapCenterToCursor
modifier
Patch Changes
-
#437
0e628bc
Thanks @chestozo! - Added PointerEvent support to thegetEventCoordinates
method. This fixes testing the PointerSensor with Cypress (#436) -
Updated dependencies [
13be602
,aede2cc
,05d6a78
,a32a4c5
,f96cb5d
,dea715c
,dbc9601
,46ec5e4
,7006464
,0e628bc
,c447880
,2ba6dfe
,8d70540
,13be602
,422d083
,c4b21b4
,5a41340
,a13dbb6
,e2ee0dc
,1fe9b5c
,1fe9b5c
,1f5ca27
]:- @dnd-kit/[email protected]
- @dnd-kit/[email protected]
@dnd-kit/[email protected]
Major Changes
-
#337
05d6a78
Thanks @clauderic! - React updates in non-synthetic event handlers are now batched to reduce re-renders and prepare for React 18.Also fixed issues with collision detection:
- Defer measurement of droppable node rects until second render after dragging.
- Use DragOverlay's width and height in collision rect (if it is used)
-
#427
f96cb5d
Thanks @clauderic! - - Using transform-agnostic measurements for the DragOverlay node.- Renamed the
overlayNode
property todragOverlay
on theDndContextDescriptor
interface.
- Renamed the
-
#372
dbc9601
Thanks @clauderic! - RefactoredDroppableContainers
type fromRecord<UniqueIdentifier, DroppableContainer
to a custom instance that extends theMap
constructor and adds a few other methods such astoArray()
,getEnabled()
andgetNodeFor(id)
.A unique
key
property was also added to theDraggableNode
andDroppableContainer
interfaces. This prevents potential race conditions in the mount and cleanup effects ofuseDraggable
anduseDroppable
. It's possible for the clean-up effect to run after another React component usinguseDraggable
oruseDroppable
mounts, which causes the newly mounted element to accidentally be un-registered. -
#379
8d70540
Thanks @clauderic! - ThelayoutMeasuring
prop ofDndContext
has been renamed tomeasuring
.The options that could previously be passed to the
layoutMeasuring
prop now need to be passed as:<DndContext - layoutMeasuring={options} + measuring={{ + droppable: options + }}
The
LayoutMeasuring
type has been renamed toMeasuringConfiguration
. TheLayoutMeasuringStrategy
andLayoutMeasuringFrequency
enums have also been renamed toMeasuringStrategy
andMeasuringFrequency
.This refactor allows consumers to configure how to measure both droppable and draggable nodes. By default,
@dnd-kit
ignores transforms when measuring draggable nodes. This beahviour can now be configured:import { DndContext, getBoundingClientRect, MeasuringConfiguration, } from '@dnd-kit/core'; const measuringConfig: MeasuringConfiguration = { draggable: { measure: getBoundingClientRect, }, }; function App() { return <DndContext measuring={measuringConfig} />; }
-
#350
a13dbb6
Thanks @wmain! - Breaking change: TheCollisionDetection
interface has been refactored. It now receives an object that contains theactive
draggable node, along with thecollisionRect
and an array ofdroppableContainers
.If you've built custom collision detection algorithms, you'll need to update them. Refer to this PR for examples of how to refactor collision detection functions to the new
CollisionDetection
interface.The
sortableKeyboardCoordinates
method has also been updated since it relies on theclosestCorners
collision detection algorithm. If you were using collision detection strategies in a customsortableKeyboardCoordinates
method, you'll need to update those as well.
Minor Changes
-
#334
13be602
Thanks @trentmwillis! - Now passingactivatorEvent
as an argument tomodifiers
-
#376
aede2cc
Thanks @clauderic! - Mouse, Pointer, Touch sensors now cancel dragging on visibility change and window resize. The Keyboard sensor already cancelled dragging on window resize. It now also cancels dragging on visibility change. -
#399
a32a4c5
Thanks @supersebh! - Added support fortolerance
in DistanceConstrain. As soon as thetolerance
is exceeded, the drag operation will be aborted, unless it has already started (because distance criteria was met).Example usage:
// Require the pointer be moved by 10 pixels vertically to initiate drag operation // Abort if the pointer is moved by more than 5 pixels horizontally. { distance: {y: 10}, tolerance: {x: 5}, }
Be careful not to pick conflicting settings for distance and tolerance if used together. For example, picking a tolerance that is lower than the distance in the same axis would result in the activation constraint never being met.
-
#408
dea715c
Thanks @wmain! - The collision rect is now completely based on the position of theDragOverlay
when it is used. Previously, only thewidth
andheight
properties of theDragOverlay
were used for the collision rect, while thetop
,left
,bottom
andright
properties were derived from the active node rect. This new approach is more aligned with developers would expect, but could cause issues for consumers that were relying on the previous (incorrect) behavior. -
#433
c447880
Thanks @clauderic! - Fix unwanted animations when items in sortable context change -
#415
2ba6dfe
Thanks @cantrellnm! - PreventgetScrollableAncestors
from continuing to search if a fixed position node is found. -
#377
422d083
Thanks @clauderic! - Pointer, Mouse and Touch sensors now stop propagation of click events once activation constraints are met. -
#375
c4b21b4
Thanks @clauderic! - Prevent context menu from opening when pointer sensor is active -
5a41340
Thanks @clauderic! - Pointer, Mouse and Touch sensors now prevent selection changes and clear any existing selection ranges once activation constraints are met. -
e2ee0dc
Thanks @clauderic! - Reset theover
internal state of<DndContext />
on drop. -
1fe9b5c
Thanks @clauderic! - Sensors may now specify a staticsetup
method that will be invoked when<DndContext>
mounts. The setup method may optionally also return a teardown function that will be invoked when the<DndContext>
associated with that sensor unmounts.
Patch Changes
-
#430
46ec5e4
Thanks @clauderic! - Fix duplicate scroll ancestor detection. In some scenarios, an element could be added twice to the list of detected scrollable ancestors, resulting in invalid offsets. -
#371
7006464
Thanks @clauderic! - fix: do not wrap consumer-defined handlers in batchedUpdates -
1fe9b5c
Thanks @clauderic! - The TouchSensor attempts to prevent the default browser behavior of scrolling the page by callingevent.preventDefault()
in thetouchmove
event listener. This wasn't working in iOS Safari due to a bug with dynamically attachedtouchmove
event listeners. Adding a non-passive, non-capturetouchmove
event listener before dynamically attaching othertouchmove
event listeners solves the issue. -
Updated dependencies [
0e628bc
, [13be602
](htt...
@dnd-kit/[email protected]
Patch Changes
-
dbe0087
#335 Thanks @clauderic! - FixgetEventListenerTarget
when target element is not an instance ofHTMLElement
-
5d4d292
#331 Thanks @phungleson! - Fix typo inSensorContext
type (scrollAdjustedTransalte
-->scrollAdjustedTranslate
)
@dnd-kit/[email protected]
Patch Changes
- Updated dependencies [
d39ab11
]:- @dnd-kit/[email protected]