Problem with Select2 and inline editing - possible bug?

Problem with Select2 and inline editing - possible bug?

simoncunsimoncun Posts: 16Questions: 5Answers: 0

Hi,

I've a problem with the Select2 plugin and inline editing. If I click the cell it shows the Select2 box with the search box focused as expected. However, if I click on the search box (or on any white space that isn't an option in the select) the datatables cell loses focus, the Select2 dropdown remains visible. Clicking on white space below the dropdown doesn't remove it and choosing an option doesn't update datatables.

I can't link to a live version right now but I've uploaded screenshots of a basic example, imgur.com/a/XHcYG.

I'm using the latest version of datatables, editor and 4.0.1 (and later) of Select2. I've stripped out all styles except of the base editor style and the Select2 style but hopefully you'll get the idea.

Answers

  • kthorngrenkthorngren Posts: 20,389Questions: 26Answers: 4,784
    edited February 2017

    I see the same issue unless I enable multiple: true in the Select2 opts.

    Kevin

  • simoncunsimoncun Posts: 16Questions: 5Answers: 0

    Yes but it leads to more problems, e.g. deleting one of the multiple options leads to the same issue or clicking on white space below the dropdown just leaves it open. Is Select2 workable or is Selectize better?

  • kthorngrenkthorngren Posts: 20,389Questions: 26Answers: 4,784

    Yes but it leads to more problems, e.g. deleting one of the multiple options leads to the same issue

    I hadn't noticed that before but I can recreate that issue. My project is still in development and has not had much testing :-)

    Hopefully its an easy fix.

    Kevin

  • simoncunsimoncun Posts: 16Questions: 5Answers: 0

    I scrapped Select2 and went with Selectize with a plugin from their git that makes it work the same. https://github.com/selectize/selectize.js/pull/776/files

  • martin@mp-networks.netmartin@mp-networks.net Posts: 5Questions: 2Answers: 0
    edited February 2017

    Found a solution for this.

    https://github.com/select2/select2/issues/1246

    if ($.ui && $.ui.dialog && $.ui.dialog.prototype._allowInteraction) {
    var ui_dialog_interaction = $.ui.dialog.prototype._allowInteraction;
    $.ui.dialog.prototype._allowInteraction = function(e) {
    if ($(e.target).closest('.select2-dropdown').length) return true;
    return ui_dialog_interaction.apply(this, arguments);
    };
    }

This discussion has been closed.