Skip to content

Commit

Permalink
Merge pull request #5973 from avalonmediasystem/dropdown_focus
Browse files Browse the repository at this point in the history
Prevent keyboard opening for playlist dropdown on mobile devices
  • Loading branch information
masaball authored Aug 12, 2024
2 parents bf3b288 + cf09bb8 commit 4d2fff5
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions app/assets/javascripts/player_listeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
let canvasIndex = -1;
let currentSectionLabel = undefined;
let addToPlaylistListenersAdded = false;
let searchFieldListenerAdded = false
let firstLoad = true;
let streamId = '';
let isMobile = false;
Expand Down Expand Up @@ -324,6 +325,23 @@ function addToPlaylistListeners(sectionIds, mediaObjectId) {
}
});

// Set playlist search box to readonly in mobile browsers to prevent
// keyboard from popping up when opening playlist dropdown.
$('.select2-selection').on("click", function () {
const IS_TOUCH_ONLY = navigator.maxTouchPoints && navigator.maxTouchPoints > 2 && !window.matchMedia("(pointer: fine").matches;
let searchField = $('.select2-search__field');
if ((/Mobi|iPhone/i.test(window.navigator.userAgent) || IS_TOUCH_ONLY) && searchField.length > 0) {
searchField.attr('readonly', 'readonly')
if (!searchFieldListenerAdded) {
searchField.on('click', function(e) {
searchField.removeAttr('readonly').select();
});

searchFieldListenerAdded = true
}
}
});

addToPlaylistListenersAdded = true;
}

Expand Down

0 comments on commit 4d2fff5

Please sign in to comment.