3

I'm trying to get the editor to open on a single tap of a cell in handsontable using a mobile device. The current functionality requires the user to double-tap the cell to enable editing, but my requirement is to have this work when the user selects the cell with a single tap.

I searched and found this answer which goes some way to helping. When I use the following code the editor behaves the way I want it to when using a single mouse click, but fails to fire on a touch event:

Handsontable.hooks.add( 'afterSelectionEnd', function() {
        this.getActiveEditor().beginEditing();
    });

Looking through the handsontable code it looks like the 'afterSelectionEnd' hook is triggered by mouse events but not touch events. I'm hoping there's a solution that doesn't involve modifying the original source, but at the moment I'm not having any luck.

Community
  • 1
  • 1
genesisfan
  • 31
  • 1
  • 4

1 Answers1

1

You can fire the afterSelectionEnd hook manually using an event listener for the touchend event.

document.body.addEventListener('touchend', function(event){
    Handsontable.hooks.run(hot, 'afterSelectionEnd');
});

JS Fiddle

Tym Pollack
  • 125
  • 2
  • 9