Skip to content

Commit

Permalink
Disable search in multiple select field for Other Options field when …
Browse files Browse the repository at this point in the history
…not selected (#3500)

Improve Option field
  • Loading branch information
haslinghuis authored Aug 24, 2023
1 parent de9077a commit 20c3764
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/js/tabs/firmware_flasher.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,19 @@ firmware_flasher.initialize = function (callback) {
$('select[name="radioProtocols"]').select2();
$('select[name="telemetryProtocols"]').select2();
$('select[name="motorProtocols"]').select2();
$('select[name="options"]').select2({ closeOnSelect: false });
$('select[name="options"]').select2({ tags: false, closeOnSelect: false });
$('select[name="commits"]').select2({ tags: true });

$('select[name="options"]')
.on('select2:opening', function() {
const searchfield = $(this).parent().find('.select2-search__field');
searchfield.prop('disabled', false);
})
.on('select2:closing', function() {
const searchfield = $(this).parent().find('.select2-search__field');
searchfield.prop('disabled', true);
});

$('select[name="radioProtocols"]').on("select2:select", function() {
const selectedProtocol = $('select[name="radioProtocols"] option:selected').first().val();
if (selectedProtocol) {
Expand Down Expand Up @@ -502,6 +512,7 @@ firmware_flasher.initialize = function (callback) {
'select[name="options"]',
'select[name="commits"]',
];

$(document).on('select2:open', select2Elements.join(','), () => {
const allFound = document.querySelectorAll('.select2-container--open .select2-search__field');
$(this).one('mouseup keyup', () => {
Expand Down

0 comments on commit 20c3764

Please sign in to comment.