From b318da59e0f9cdc12db899b4fb48ec1c62184f18 Mon Sep 17 00:00:00 2001 From: xLaura3m5 Date: Mon, 29 Jul 2024 20:39:56 +0200 Subject: [PATCH 1/3] TASK: update snapshot --- .../MultiSelectBox/__snapshots__/multiSelectBox.spec.js.snap | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/react-ui-components/src/MultiSelectBox/__snapshots__/multiSelectBox.spec.js.snap b/packages/react-ui-components/src/MultiSelectBox/__snapshots__/multiSelectBox.spec.js.snap index f80ef82090..21c533efe2 100644 --- a/packages/react-ui-components/src/MultiSelectBox/__snapshots__/multiSelectBox.spec.js.snap +++ b/packages/react-ui-components/src/MultiSelectBox/__snapshots__/multiSelectBox.spec.js.snap @@ -13,6 +13,7 @@ exports[` should render correctly. 1`] = ` ListPreviewElement={[Function]} MultiSelectBox_ListPreviewSortable={[Function]} SelectBox={[Function]} + allowDragging={true} allowEmpty={true} dndType="multiselect-box-value" onCreateNew={[MockFunction]} @@ -28,6 +29,7 @@ exports[` should render correctly. 1`] = ` ListPreviewElement={[Function]} MultiSelectBox_ListPreviewSortable={[Function]} SelectBox={[Function]} + allowDragging={true} allowEmpty={true} dndType="multiselect-box-value" onCreateNew={[MockFunction]} From 99c28da275dcd59bdd0abc7093459635100fa837 Mon Sep 17 00:00:00 2001 From: xLaura3m5 Date: Mon, 22 Jul 2024 21:25:48 +0200 Subject: [PATCH 2/3] TASK: set default value for allowDragging --- .../react-ui-components/src/MultiSelectBox/multiSelectBox.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react-ui-components/src/MultiSelectBox/multiSelectBox.js b/packages/react-ui-components/src/MultiSelectBox/multiSelectBox.js index 0574f842cc..ed8a3e8015 100644 --- a/packages/react-ui-components/src/MultiSelectBox/multiSelectBox.js +++ b/packages/react-ui-components/src/MultiSelectBox/multiSelectBox.js @@ -165,6 +165,7 @@ class MultiSelectBox extends PureComponent { optionValueField: 'value', dndType: 'multiselect-box-value', allowEmpty: true, + allowDragging: true, ListPreviewElement: SelectBox_Option_SingleLine } From 675e8034c07e7d3840f780ce6da28eda9d433a57 Mon Sep 17 00:00:00 2001 From: xLaura3m5 Date: Fri, 12 Jul 2024 17:30:01 +0200 Subject: [PATCH 3/3] TASK: introduce allowDragging prop on MultiSelectBox --- .../src/MultiSelectBox/multiSelectBox.js | 5 +++++ .../multiSelectBox_ListPreviewSortable.js | 1 + ...Box_ListPreviewSortable_DraggableListPreviewElement.js | 8 +++++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/react-ui-components/src/MultiSelectBox/multiSelectBox.js b/packages/react-ui-components/src/MultiSelectBox/multiSelectBox.js index ed8a3e8015..9d01c64ca0 100644 --- a/packages/react-ui-components/src/MultiSelectBox/multiSelectBox.js +++ b/packages/react-ui-components/src/MultiSelectBox/multiSelectBox.js @@ -31,6 +31,11 @@ class MultiSelectBox extends PureComponent { */ disabled: PropTypes.bool, + /** + * Allows dragging. + */ + allowDragging: PropTypes.bool, + /** * Additional className wich will be applied */ diff --git a/packages/react-ui-components/src/MultiSelectBox_ListPreviewSortable/multiSelectBox_ListPreviewSortable.js b/packages/react-ui-components/src/MultiSelectBox_ListPreviewSortable/multiSelectBox_ListPreviewSortable.js index c26222feaf..e5094e1af6 100644 --- a/packages/react-ui-components/src/MultiSelectBox_ListPreviewSortable/multiSelectBox_ListPreviewSortable.js +++ b/packages/react-ui-components/src/MultiSelectBox_ListPreviewSortable/multiSelectBox_ListPreviewSortable.js @@ -31,6 +31,7 @@ export default class MultiSelectBox_ListPreviewSortable extends PureComponent { values: PropTypes.arrayOf(PropTypes.string), onValuesChange: PropTypes.func.isRequired, ListPreviewElement: PropTypes.any.isRequired, + allowDragging: PropTypes.bool, // API with MultiSelectBox optionValueAccessor: PropTypes.func.isRequired diff --git a/packages/react-ui-components/src/MultiSelectBox_ListPreviewSortable_DraggableListPreviewElement/multiSelectBox_ListPreviewSortable_DraggableListPreviewElement.js b/packages/react-ui-components/src/MultiSelectBox_ListPreviewSortable_DraggableListPreviewElement/multiSelectBox_ListPreviewSortable_DraggableListPreviewElement.js index 569956bacf..530d7a3611 100644 --- a/packages/react-ui-components/src/MultiSelectBox_ListPreviewSortable_DraggableListPreviewElement/multiSelectBox_ListPreviewSortable_DraggableListPreviewElement.js +++ b/packages/react-ui-components/src/MultiSelectBox_ListPreviewSortable_DraggableListPreviewElement/multiSelectBox_ListPreviewSortable_DraggableListPreviewElement.js @@ -48,8 +48,8 @@ const spec = { index: props.index }; }, - canDrag({values, disabled}) { - return !disabled && (values && values.length > 1); + canDrag({values, disabled, allowDragging}) { + return allowDragging && !disabled && (values && values.length > 1); } }, (connect, monitor) => ({ connectDragSource: connect.dragSource(), @@ -65,6 +65,7 @@ export default class MultiSelectBox_ListPreviewSortable_DraggableListPreviewElem }), values: PropTypes.arrayOf(PropTypes.string), disabled: PropTypes.bool, + allowDragging: PropTypes.bool, // Drag&Drop specific propTypes dndType: PropTypes.string.isRequired, @@ -103,6 +104,7 @@ export default class MultiSelectBox_ListPreviewSortable_DraggableListPreviewElem const { option, disabled, + allowDragging, connectDragSource, connectDropTarget, isDragging, @@ -117,7 +119,7 @@ export default class MultiSelectBox_ListPreviewSortable_DraggableListPreviewElem // TODO Loading State: const {icon, label} = option || {label: `[Loading ${value}]`}; - const isDraggable = !disabled && (values && values.length > 1); + const isDraggable = allowDragging && !disabled && (values && values.length > 1); const finalClassNames = mergeClassNames({ [theme.selectedOptions__item]: true,