MDL-68778 user: Fetch select from selected option
authorAndrew Nicols <andrew@nicols.co.uk>
Wed, 20 May 2020 00:47:02 +0000 (08:47 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Wed, 20 May 2020 05:17:50 +0000 (13:17 +0800)
It seems that the HTMLSelectElement behaves slightly different on Linux
vs MacOS.

On Linux with Firefox 47 when selecting an option the
HTMLOptionElement is returned, whereas on MavOS the HTMLSelectElement
that the Option belongs to is returned.

We need to normalise the value here before resetting the currently
selected item.

user/amd/build/participants.min.js
user/amd/build/participants.min.js.map
user/amd/src/participants.js

index b963d28..0038432 100644 (file)
Binary files a/user/amd/build/participants.min.js and b/user/amd/build/participants.min.js differ
index 7a9ea4a..0866a37 100644 (file)
Binary files a/user/amd/build/participants.min.js.map and b/user/amd/build/participants.min.js.map differ
index f9b62a6..e56541c 100644 (file)
@@ -59,7 +59,8 @@ export const init = ({
     const registerEventListeners = () => {
         CustomEvents.define(Selectors.bulkActionSelect, [CustomEvents.events.accessibleChange]);
         jQuery(Selectors.bulkActionSelect).on(CustomEvents.events.accessibleChange, e => {
-            const action = e.target.value;
+            const bulkActionSelect = e.target.closest('select');
+            const action = bulkActionSelect.value;
             const tableRoot = getTableFromUniqueId(uniqueid);
             const checkboxes = tableRoot.querySelectorAll(Selectors.bulkUserSelectedCheckBoxes);
 
@@ -88,8 +89,7 @@ export const init = ({
                     .then(modal => {
                         modal.getRoot().on(ModalEvents.hidden, () => {
                             // Focus on the action select when the dialog is closed.
-                            const bulkActionSelector = root.querySelector(Selectors.bulkActionSelect);
-                            bulkActionSelector.focus();
+                            bulkActionSelect.focus();
                         });
 
                         return modal;
@@ -97,10 +97,10 @@ export const init = ({
                     .catch(Notification.exception);
                 }
             } else if (action !== '' && checkboxes.length) {
-                e.target.form.submit();
+                bulkActionSelect.form.submit();
             }
 
-            resetBulkAction(e.target);
+            resetBulkAction(bulkActionSelect);
         });
 
         root.addEventListener('click', e => {