Fix for the occasional: Uncaught TypeError: Cannot read property 'selectedItems' of undefined