olifolkerd / tabulator

Interactive Tables and Data Grids for JavaScript
http://tabulator.info
MIT License
6.78k stars 821 forks source link

Left/Right arrow keys wont move text caret on inputs when editing a cell with selectableRange enabled #4563

Open cpgo opened 3 months ago

cpgo commented 3 months ago

Describe the bug When editing a cell and the table has selectableRange enabled left and right arrow keys will not move the input cursor

Tabulator Info

Working Example https://jsfiddle.net/4fc5s8oa/6/ Or the example on docs https://tabulator.info/docs/6.2/range#clipboard

To Reproduce A step by step guide to recreate the issue in your JS Fiddle or Codepen:

  1. Enable selectableRange
  2. Open any cell editor via either Enter key or single/double clicking depending on editTriggerEvent
  3. Try hitting left key to edit a single letter on the cell input
  4. See error

Expected behavior I would expect the input to work like a normal input, meaning I can navigate with keyboard or click somewhere on the text to move the input caret

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context I see that the text area input (https://tabulator.info/docs/6.2/edit#editor-textarea) has a verticalNavigation option that almost does what I expect, but as the name suggest only navigating up or down, I tried looking at the code to see if I could implement a horizontalNavigation option but had no luck

cpgo commented 3 months ago

Found this workaround for now, not sure if this will break anything else

    Tabulator.extendModule("keybindings", "actions", {
      rangeExpandLeft: function(e) {
        if (this.table.modules.edit.currentCell) {
          return;
        }

        this.dispatch("keybinding-nav-range", e, "left", false, true);
      },
      rangeExpandRight: function(e) {
        if (this.table.modules.edit.currentCell) {
          return;
        }

        this.dispatch("keybinding-nav-range", e, "right", false, true);
      },
      navLeft: function(e) {
        if (this.table.modules.edit.currentCell) {
          return;
        }

        this.dispatch("keybinding-nav-left", e);
      },
      navRight: function(e) {
        if (this.table.modules.edit.currentCell) {
          return;
        }

        this.dispatch("keybinding-nav-right", e);
      },
    });

Still trying to keep the editor open when clicking inside the input but still havent found what module to extend to do that.

ValyaSHmelev commented 3 months ago

Faced the same problem, thanks for the temporary solution

ainars-sk commented 2 months ago

+1. I've faced the same issue, but I've managed to sort it out by rolling back to version 6.2.0 - it does not have this glitch. Thanks to @cpgo for JSFiddle - I was decreasing minor version one by one till I've got it fixed :)

Hoogkamer commented 1 month ago

Thanks, version 6.2.0 works. The solution by cpgo works for the arrow keys, however it does not work when you want to click and put the cursor at a specific place in the cell to edit it.

cpgo commented 1 month ago

however it does not work when you want to click and put the cursor at a specific place in the cell to edit it

Yeah, I could not find a workaround for that.

In the end we needed a bit more features that were not available out of the box on tabulator and moved away to another library. Still really like tabulator for simpler data grids tho