KeyTable issue

KeyTable issue

tomsve63tomsve63 Posts: 1Questions: 1Answers: 0

I have a question about these lines of code from the KeyTable extension, version 2.12.1:

        // Key events
        $(document).on('keydown' + namespace, function (e) {
            if (!editorBlock && !that.s.dtDrawing) {
                that._key(e);
            }
            else {
                e.preventDefault();
            }
        });

So, if the condition above is not fulfilled no "keydown" events at all are handled in my page!
In my application all input fields stopped working.
After some investigation I found out that "dtDrawing" above is set to true when the "preDraw"
notification for a table is received and it is later set to false when "draw" notification is received.

However, if "draw" is not sent it will remain true.

My application has multiple tables, some of which have "preDraw" callbacks that may return false.
This inhibits the draw to be performed.

Each time any key is pressed, e.g. to type into an input field outside of the tables,
the handlers of all tables are walked through to check if the focus belongs to any of them.
If one of them has "dtDrawing" state true the preventDefault() method of the event is called
and nothing will be typed into my input field.

My only workaround for now is to remove the "preDraw" callback.
Did I misunderstand anything?
Do you have any suggestions how to get around the problem?

Maybe just removing the "else" clause would solve the problem?

Btw, I use the extension only for row navigation. Is there a more lightweight way to achieve that?

Answers

  • allanallan Posts: 62,858Questions: 1Answers: 10,344 Site admin

    Good question. For such a case there perhaps needs to be a preDrawCancelled event that KeyTable can listen for and clear its dtDrawing flag.

    That said, as the documentation for preDraw notes, cancelling a draw action can result in unpredictable behaviour, since the table's internals might have been updated (sorting, paging, filtering all changed), so keyboard navigation between the rows and cells would most likely be off (not just the keyboard but many API interactions).

    For things to go back to normal, a draw restoring the state that you want is really needed.

    What condition(s) do you use to cancel a draw action?

    Allan

Sign In or Register to comment.