ce icon indicating copy to clipboard operation
ce copied to clipboard

Selection is disappearing when select rows from bottom to top / select columns from right to left

Open dt-reshape opened this issue 3 years ago • 5 comments

Step 1: Select rows from bottom to top / select columns from right to left image image Step 2: Right-click on the selected area image image

Expected result: Selection should not disappear Actual result: Selection is disappearing

dt-reshape avatar Dec 21 '21 11:12 dt-reshape

Hi,

I can't reproduct your error. But you have index text align set to left, maybe it's link with that ? I have checked on that : https://bossanova.uk/jspreadsheet/v4/

GBonnaire avatar Dec 27 '21 08:12 GBonnaire

I have recorded an example of the error https://www.youtube.com/watch?v=Q-EEXeb7DUE

dt-reshape avatar Dec 27 '21 13:12 dt-reshape

@hodeware hi there, any good luck? Because i am still stuck in this issue.

b-solution avatar Sep 19 '22 11:09 b-solution

Hi,

While waiting for the patch on jspreadsheet CE, you can use this script

add on your event onload


const myTable = jspreadsheet(HTMLDomElement, {
    /* ..your config.. */
   onload: function(instance) {
        instance.el.addEventListener("contextmenu", function(e) {
             const currentSelection = instance.selectedCell;
             const x1 = Math.min(parseInt(currentSelection[0]), parseInt(currentSelection[2])),
                   x2 = Math.max(parseInt(currentSelection[0]), parseInt(currentSelection[2]));
             const y1 = Math.min(parseInt(currentSelection[1]), parseInt(currentSelection[3])),
                   y2 = Math.max(parseInt(currentSelection[1]), parseInt(currentSelection[3]));
             if(parseInt(currentSelection[0]) != x1 || parseInt(currentSelection[1]) != y1) {
                   instance.updateSelectionFromCoords(x1, y1, x2, y2);
             }
        });
   }
});

GBonnaire avatar Sep 19 '22 12:09 GBonnaire

@GBonnaire I had to update a little bit your script for my needs, but it works !

onload = async (instance, jexcel) => {
    instance.addEventListener('contextmenu', function (e) {
      const currentSelection = jexcel.selectedCell;
      const x1 = Math.min(
          parseInt(currentSelection[0]),
          parseInt(currentSelection[2])
        ),
        x2 = Math.max(
          parseInt(currentSelection[0]),
          parseInt(currentSelection[2])
        );
      const y1 = Math.min(
          parseInt(currentSelection[1]),
          parseInt(currentSelection[3])
        ),
        y2 = Math.max(
          parseInt(currentSelection[1]),
          parseInt(currentSelection[3])
        );
      if (
        parseInt(currentSelection[0]) != x1 ||
        parseInt(currentSelection[1]) != y1
      ) {
        jexcel.updateSelectionFromCoords(x1, y1, x2, y2);
      }
    });
    ... // more content
};

hourlier96 avatar Apr 13 '23 15:04 hourlier96