Skip to content

Commit 4994bc8

Browse files
authored
Merge pull request #640 from IgniteUI/mkirova/fix-613
fix(drag): Fix issue with drag&drop custom samples.
2 parents 0d41ada + 44324af commit 4994bc8

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

samples/grids/grid/row-drag-base/src/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ export default function App() {
2222
const ghostElement = evt.detail.dragDirective.ghostElement;
2323
if (ghostElement != null) {
2424
const dragElementPos = ghostElement.getBoundingClientRect();
25-
const gridPosition = document.getElementById("rightGrid").getBoundingClientRect();
25+
const gridPosition = document.getElementById("rightGrid").getElementsByTagName("igc-grid")[0].getBoundingClientRect();
2626

2727
const withinXBounds = dragElementPos.x >= gridPosition.x && dragElementPos.x <= gridPosition.x + gridPosition.width;
2828
const withinYBounds = dragElementPos.y >= gridPosition.y && dragElementPos.y <= gridPosition.y + gridPosition.height;
2929
if (withinXBounds && withinYBounds) {
30-
grid.deleteRow(evt.detail.dragData.index);
30+
grid.deleteRow(evt.detail.dragData.key);
3131
rightGridRef.current.addRow(evt.detail.dragData.data);
3232
}
3333
}
@@ -36,7 +36,7 @@ export default function App() {
3636
return (
3737
<div className="container sample">
3838
<div className="container horizontal wrapper">
39-
<IgrGrid data={data} width="40%" autoGenerate="false" rowDraggable="true" rowDragEnd={onGridRowDragEnd}>
39+
<IgrGrid data={data} width="40%" primaryKey='ID' autoGenerate="false" rowDraggable="true" rowDragEnd={onGridRowDragEnd}>
4040
<IgrColumn field="ID" width="100px"></IgrColumn>
4141
<IgrColumn field="CompanyName" width="100px"></IgrColumn>
4242
<IgrColumn field="ContactName" width="100px"></IgrColumn>

samples/grids/hierarchical-grid/row-drag-base/src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default function App() {
2727
const ghostElement = evt.detail.dragDirective.ghostElement;
2828
if (ghostElement != null) {
2929
const dragElementPos = ghostElement.getBoundingClientRect();
30-
const gridPosition = document.getElementById("hierarchicalGrid2").getBoundingClientRect();
30+
const gridPosition = document.getElementById("hierarchicalGrid2").getElementsByTagName("igc-hierarchical-grid")[0].getBoundingClientRect();
3131

3232
const withinXBounds = dragElementPos.x >= gridPosition.x && dragElementPos.x <= gridPosition.x + gridPosition.width;
3333
const withinYBounds = dragElementPos.y >= gridPosition.y && dragElementPos.y <= gridPosition.y + gridPosition.height;

samples/grids/tree-grid/row-drag-base/src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default function App() {
3636
const ghostElement = evt.detail.dragDirective.ghostElement;
3737
if (ghostElement != null) {
3838
const dragElementPos = ghostElement.getBoundingClientRect();
39-
const gridPosition = document.getElementById("treeGrid2").getBoundingClientRect();
39+
const gridPosition = document.getElementById("treeGrid2").getElementsByTagName("igc-tree-grid")[0].getBoundingClientRect();
4040

4141
const withinXBounds = dragElementPos.x >= gridPosition.x && dragElementPos.x <= gridPosition.x + gridPosition.width;
4242
const withinYBounds = dragElementPos.y >= gridPosition.y && dragElementPos.y <= gridPosition.y + gridPosition.height;

0 commit comments

Comments
 (0)