mirror of https://github.com/grafana/grafana.git
DashboardLayoutOrchestrator: Refine drag drop logic (#106079)
This commit is contained in:
parent
c23ee1e116
commit
3b78078ea4
|
@ -30,4 +30,30 @@ describe('Dashboard', () => {
|
||||||
.should('be.higherThan', panel3);
|
.should('be.higherThan', panel3);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Note, moving a panel from a nested row to a parent row currently just deletes the panel
|
||||||
|
// This test will need to be updated once the correct behavior is implemented.
|
||||||
|
it('can move panel from nested row to parent row', () => {
|
||||||
|
e2e.flows.openDashboard({ uid: `${PAGE_UNDER_TEST}?orgId=1` });
|
||||||
|
|
||||||
|
e2e.flows.scenes.toggleEditMode();
|
||||||
|
|
||||||
|
e2e.flows.scenes.groupIntoRow();
|
||||||
|
e2e.flows.scenes.groupIntoRow();
|
||||||
|
|
||||||
|
cy.get('[data-testid="data-testid dashboard-row-title-New row"]')
|
||||||
|
.first()
|
||||||
|
.then((el) => {
|
||||||
|
const rect = el.offset();
|
||||||
|
e2e.components.Panels.Panel.headerContainer()
|
||||||
|
.contains(/^Panel one$/)
|
||||||
|
.trigger('pointerdown', { which: 1 })
|
||||||
|
.trigger('pointermove', { clientX: rect.left, clientY: rect.top })
|
||||||
|
.trigger('pointerup');
|
||||||
|
});
|
||||||
|
|
||||||
|
e2e.components.Panels.Panel.headerContainer()
|
||||||
|
.contains(/^Panel one$/)
|
||||||
|
.should('not.exist');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -101,13 +101,17 @@ export class DashboardLayoutOrchestrator extends SceneObjectBase<DashboardLayout
|
||||||
}
|
}
|
||||||
|
|
||||||
private _getDropTargetUnderMouse(evt: MouseEvent): DashboardDropTarget | null {
|
private _getDropTargetUnderMouse(evt: MouseEvent): DashboardDropTarget | null {
|
||||||
const key = document
|
const elementsUnderPoint = document.elementsFromPoint(evt.clientX, evt.clientY);
|
||||||
.elementsFromPoint(evt.clientX, evt.clientY)
|
const cursorIsInSourceTarget = elementsUnderPoint.some(
|
||||||
?.find((element) => {
|
(el) => el.getAttribute('data-dashboard-drop-target-key') === this._sourceDropTarget?.state.key
|
||||||
const key = element.getAttribute('data-dashboard-drop-target-key');
|
);
|
||||||
|
|
||||||
return !!key && key !== this._sourceDropTarget?.state.key;
|
if (cursorIsInSourceTarget) {
|
||||||
})
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const key = elementsUnderPoint
|
||||||
|
?.find((element) => element.getAttribute('data-dashboard-drop-target-key'))
|
||||||
?.getAttribute('data-dashboard-drop-target-key');
|
?.getAttribute('data-dashboard-drop-target-key');
|
||||||
|
|
||||||
if (!key) {
|
if (!key) {
|
||||||
|
|
Loading…
Reference in New Issue