Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,6 @@ describe('GenericDragAndDropController', () => {
return ariaPressedTarget.call(controller, el);
}

function callResolveMirrorContainer():Element {
const resolveMirrorContainer = Reflect.get(controller, 'resolveMirrorContainer') as (
this:GenericDragAndDropController
) => Element;

return resolveMirrorContainer.call(controller);
}

describe('canStartDrag', () => {
it('allows dragging a draggable row in handle-less mode', () => {
const row = draggableRow();
Expand Down Expand Up @@ -155,21 +147,4 @@ describe('GenericDragAndDropController', () => {
expect(callAriaPressedTarget(row)).toBe(handle);
});
});

describe('resolveMirrorContainer', () => {
it('returns the configured mirror container target when present', () => {
const mirrorContainer = document.createElement('div');

Object.defineProperty(controller, 'hasMirrorContainerTarget', { value: true, configurable: true });
Object.defineProperty(controller, 'mirrorContainerTarget', { value: mirrorContainer, configurable: true });

expect(callResolveMirrorContainer()).toBe(mirrorContainer);
});

it('falls back to document.body when no mirror container target exists', () => {
Object.defineProperty(controller, 'hasMirrorContainerTarget', { value: false, configurable: true });

expect(callResolveMirrorContainer()).toBe(document.body);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,10 @@ interface TargetConfig {
}

export default class GenericDragAndDropController extends Controller {
static targets = ['container', 'scrollContainer', 'mirrorContainer'];
static targets = ['container', 'scrollContainer'];

containerTargets:HTMLElement[];
scrollContainerTargets:HTMLElement[];
declare readonly hasMirrorContainerTarget:boolean;
declare readonly mirrorContainerTarget:HTMLElement;

static values = {
handle: { type: Boolean, default: true },
Expand Down Expand Up @@ -129,7 +127,6 @@ export default class GenericDragAndDropController extends Controller {
moves: (el, _source, handle, _sibling) => this.canStartDrag(el, handle),
accepts: (el:Element, target:Element, source:Element, sibling:Element) => this.accepts(el, target, source, sibling),
revertOnSpill: true, // enable reverting of elements if they are dropped outside of a valid target
mirrorContainer: this.resolveMirrorContainer(),
},
)
.on('cloned', (clone, _original, type) => {
Expand Down Expand Up @@ -260,10 +257,6 @@ export default class GenericDragAndDropController extends Controller {
return container;
}

private resolveMirrorContainer():Element {
return this.hasMirrorContainerTarget ? this.mirrorContainerTarget : document.body;
}

// Returns the data-draggable-id of the element preceding el in its container,
// or null if el is the first item (signals "move to top").
private resolveTargetPrevious(el:Element):string|null {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def folded?

def drop_target_config
{
generic_drag_and_drop_target: "container mirrorContainer",
generic_drag_and_drop_target: "container",
target_container_accessor: ":scope > ul",
target_id: backlog_bucket.persisted? ? "backlog_bucket:#{backlog_bucket.id}" : "inbox",
target_allowed_drag_type: "story"
Comment thread
myabc marked this conversation as resolved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def middle_count

def drop_target_config
{
generic_drag_and_drop_target: "container mirrorContainer",
generic_drag_and_drop_target: "container",
target_container_accessor: ":scope > ul",
target_id: "inbox",
target_allowed_drag_type: "story"
Comment thread
myabc marked this conversation as resolved.
Expand Down
20 changes: 0 additions & 20 deletions modules/backlogs/spec/requests/backlogs/backlog_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,26 +106,6 @@
expect(response.body).to include('id="sprint_backlogs_container"')
end
end

it "uses the inbox border box as the drag mirror container" do
get "/projects/#{project.identifier}/backlogs/backlog", headers: { "Turbo-Frame" => "backlogs_container" }

expect(response).to have_http_status(:ok)
expect(response.body).to include(%(id="inbox_#{project.id}"))
expect(response.body).to include('data-generic-drag-and-drop-target="container mirrorContainer"')
end

context "with backlog buckets enabled", with_flag: { backlog_buckets: true } do
shared_let(:backlog_bucket) { create(:backlog_bucket, project:) }

it "uses each backlog bucket border box as the drag mirror container" do
get "/projects/#{project.identifier}/backlogs/backlog", headers: { "Turbo-Frame" => "backlogs_container" }

expect(response).to have_http_status(:ok)
expect(response.body).to include(%(data-test-selector="backlog-bucket-#{backlog_bucket.id}"))
expect(response.body).to include('data-generic-drag-and-drop-target="container mirrorContainer"')
end
end
end
end

Expand Down
Loading