Skip to content

Commit c1c2a15

Browse files
Vojtěch Václav Portešvojtechportes
authored andcommitted
fix: Fixed dragging between groups when one is read-only
1 parent 40abf80 commit c1c2a15

2 files changed

Lines changed: 51 additions & 3 deletions

File tree

src/builder.test.tsx

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { mount } from 'enzyme';
22
import React from 'react';
3-
import { Builder, IBuilderFieldProps } from './builder';
3+
import { Builder, defaultComponents, IBuilderFieldProps } from './builder';
44

55
export const fields: IBuilderFieldProps[] = [
66
{
@@ -467,4 +467,52 @@ describe('#components/Builder', () => {
467467
).toEqual(0);
468468
expect(wrapper.find('[data-test="DragHandle"]').hostNodes().length).toEqual(0);
469469
});
470+
471+
it('Keeps the boundary drop zone before a locked sibling group', () => {
472+
const wrapper = mount(
473+
<Builder
474+
fields={fields}
475+
draggable
476+
components={{
477+
...defaultComponents,
478+
DropZone: ({ index, parentId }) => (
479+
<div
480+
data-test="DropZone"
481+
data-index={index}
482+
data-parent-id={parentId || 'root'}
483+
/>
484+
),
485+
}}
486+
data={[
487+
{
488+
type: 'GROUP',
489+
value: 'AND',
490+
isNegated: false,
491+
children: [
492+
{
493+
type: 'GROUP',
494+
value: 'AND',
495+
isNegated: false,
496+
children: [],
497+
},
498+
{
499+
type: 'GROUP',
500+
value: 'AND',
501+
isNegated: false,
502+
readOnly: true,
503+
children: [],
504+
},
505+
],
506+
},
507+
]}
508+
/>
509+
);
510+
511+
expect(
512+
wrapper
513+
.find('[data-test="DropZone"]')
514+
.hostNodes()
515+
.filterWhere((node) => node.prop('data-index') === 1).length
516+
).toEqual(1);
517+
});
470518
});

src/iterator.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export const Iterator: FC<IIteratorProps> = ({
122122
);
123123

124124
if (!canSortAtLevel || isGroupReadOnly) {
125-
return [group()];
125+
return [!isCollapsedSourceBoundary ? leadingDropZone : null, group()];
126126
}
127127

128128
return [
@@ -150,7 +150,7 @@ export const Iterator: FC<IIteratorProps> = ({
150150
);
151151

152152
if (!canSortAtLevel || isRuleReadOnly) {
153-
return [rule()];
153+
return [!isCollapsedSourceBoundary ? leadingDropZone : null, rule()];
154154
}
155155

156156
return [

0 commit comments

Comments
 (0)