Posted 16 May 2022, 3:25 am EST
Hi,
This is by design to match the excel behavior. However, to prevent this you handled the mouse down and mouse up event and update the selection accordingly. Please refer to the following code snippet and attached sample that explains the same.
spread.getHost().addEventListener(
"mousedown",
function (e) {
var y = e.pageY - this.offsetTop;
var x = e.pageX - this.offsetLeft;
var result = spread.hitTest(x, y);
let floatingObject =
result?.worksheetHitInfo?.floatingObjectHitInfo?.floatingObject;
if (floatingObject) {
console.log(floatingObject);
objectInfo.isFloatingClick = true;
objectInfo.selections = spread.getActiveSheet().getSelections();
} else {
console.log(floatingObject);
objectInfo.isFloatingClick = false;
objectInfo.selections = null;
}
},
true
);
spread.getHost().addEventListener("mouseup", function (e) {
var y = e.pageY - this.offsetTop;
var x = e.pageX - this.offsetLeft;
let sheet = spread.getActiveSheet();
var result = spread.hitTest(x, y);
let floatingObject =
result?.worksheetHitInfo?.floatingObjectHitInfo?.floatingObject;
if (floatingObject && objectInfo.selections) {
objectInfo.selections.forEach(({ row, col, rowCount, colCount }) => {
sheet.addSelection(row, col, rowCount, colCount);
});
}
});
sample: https://codesandbox.io/s/spread-js-starter-forked-1ykkhf?file=/src/index.js:871-2035
References:
HitTesting: https://www.grapecity.com/spreadjs/demos/features/workbook/hit-testing#demo_source_name
Regards,
Avinash