Select extension - problem with window.getSelection

Select extension - problem with window.getSelection

ArekoAreko Posts: 3Questions: 1Answers: 0

Hi,

in function enableMouseSelection(dt) event click.dtSelect is canceled if there is any selection in window.
It is problem if I want to select row and immedietly open dialog with preselected text in input.
I found solution - changing source code:

if ( window.getSelection && $.trim( window.getSelection().toString() ) ) {
      return;
}

to

if (window.getSelection && $.trim(window.getSelection().toString())
    && window.getSelection().baseNode.parentNode.closest('table')) {
    return;
}

Have you better idea how to do it more elegant and restrict condition to current table only (not any table)?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,892Questions: 1Answers: 10,530 Site admin

    The code should only really be getting executed when activated by the selector used in the table.

    Could you give me a link to a test case showing the issue with step by step instructions how to recreate the problem please?

    Allan

  • ArekoAreko Posts: 3Questions: 1Answers: 0

    After making fiddle I see problem exist in Chrome only:
    https://jsfiddle.net/1zp1r5rz/5/
    To recreate problem try to select by clicking on "Age" column.

  • allanallan Posts: 63,892Questions: 1Answers: 10,530 Site admin
    Answer ✓

    Oh I see - thanks for the JSfiddle. I would never have thought of that!

    I'll have this fixed for the next version of Select. Until then, as a quick workaround you could use a little setTimeout() to make the text selection async. Or the change that you have made into the Select code loos sensible. I think the only change I would make is to compare the table to the table().node() element rather than just checking for a table element.

    Regards,
    Allan

  • ArekoAreko Posts: 3Questions: 1Answers: 0

    Thanks for quick answer.
    I'll make workaround and wait for next version.

This discussion has been closed.