@contentful/field-editor-reference 5.5.0 → 5.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [5.5.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@5.5.0...@contentful/field-editor-reference@5.5.1) (2022-11-07)
7
+
8
+ ### Bug Fixes
9
+
10
+ - on sort end multiple reference field ([#1273](https://github.com/contentful/field-editors/issues/1273)) ([1f7788b](https://github.com/contentful/field-editors/commit/1f7788bfb4de6a83b14c75578a43fa036202491e))
11
+
6
12
  # [5.5.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@5.4.0...@contentful/field-editor-reference@5.5.0) (2022-11-04)
7
13
 
8
14
  ### Features
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { SortEndHandler } from 'react-sortable-hoc';
2
+ import { Offset, SortEndHandler } from 'react-sortable-hoc';
3
3
  import { FieldConnector } from '@contentful/field-editor-shared';
4
4
  import type { LinkActionsProps } from '../components';
5
5
  import { Action, ActionLabels, FieldExtensionSDK, ViewType } from '../types';
@@ -30,8 +30,10 @@ export interface ReferenceEditorProps {
30
30
  updateBeforeSortStart?: ({ index }: {
31
31
  index: number;
32
32
  }) => void;
33
- onSortingEnd?: (({ index }: {
34
- index: number;
33
+ onSortingEnd?: (({ oldIndex, newIndex, }: {
34
+ oldIndex: number;
35
+ newIndex: number;
36
+ collection: Offset;
35
37
  }) => void) & SortEndHandler;
36
38
  }
37
39
  export declare type CustomActionProps = LinkActionsProps;
@@ -3296,12 +3296,18 @@ function Editor$1(props) {
3296
3296
  }, []);
3297
3297
  var onSortEnd = React.useCallback(function (_ref) {
3298
3298
  var oldIndex = _ref.oldIndex,
3299
- newIndex = _ref.newIndex;
3299
+ newIndex = _ref.newIndex,
3300
+ collection = _ref.collection;
3300
3301
  var newItems = arrayMove(items, oldIndex, newIndex);
3301
3302
  setValue(newItems);
3302
3303
  setIndexToUpdate && setIndexToUpdate(undefined);
3303
3304
  document.body.classList.remove('grabbing');
3304
- }, [items, setIndexToUpdate, setValue]);
3305
+ props.onSortingEnd && props.onSortingEnd({
3306
+ oldIndex: oldIndex,
3307
+ newIndex: newIndex,
3308
+ collection: collection
3309
+ });
3310
+ }, [items, props, setIndexToUpdate, setValue]);
3305
3311
  var onMove = React.useCallback(function (oldIndex, newIndex) {
3306
3312
  var newItems = arrayMove(items, oldIndex, newIndex);
3307
3313
  setValue(newItems);
@@ -3419,8 +3425,7 @@ function MultipleEntryReferenceEditor(props) {
3419
3425
  return React.createElement(SortableLinkList, _extends({}, childrenProps, {
3420
3426
  axis: "y",
3421
3427
  useDragHandle: true,
3422
- updateBeforeSortStart: updateBeforeSortStart,
3423
- onSortEnd: props.onSortingEnd
3428
+ updateBeforeSortStart: updateBeforeSortStart
3424
3429
  }), function (_ref2) {
3425
3430
  var items = _ref2.items,
3426
3431
  item = _ref2.item,