MDL-70075 core: Do not return a value in an event handler

Returning a value of `false` in an event handler has the effect of
calling event.preventDefault() and event.stopPropagation().

This is neither obvious, nor desirable in this situation.
This commit is contained in:
Andrew Nicols 2020-11-02 15:42:38 +08:00
parent 6cdcee7a65
commit 4edad07619
3 changed files with 7 additions and 7 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -822,7 +822,8 @@ function($, log, str, templates, notification, LoadingIcon) {
// Find the active one. // Find the active one.
var element = selectionsElement.children('[data-active-selection]'); var element = selectionsElement.children('[data-active-selection]');
if (!element.length) { if (!element.length) {
return activateSelection(0, state); activateSelection(0, state);
return;
} }
}); });
// Keyboard navigation for the selection list. // Keyboard navigation for the selection list.
@ -836,7 +837,7 @@ function($, log, str, templates, notification, LoadingIcon) {
// Choose the next selection item. // Choose the next selection item.
pendingPromise.resolve(activateNextSelection(state)); pendingPromise.resolve(activateNextSelection(state));
return false; return;
case KEYS.LEFT: case KEYS.LEFT:
case KEYS.UP: case KEYS.UP:
// We handled this event, so prevent it. // We handled this event, so prevent it.
@ -844,7 +845,7 @@ function($, log, str, templates, notification, LoadingIcon) {
// Choose the previous selection item. // Choose the previous selection item.
pendingPromise.resolve(activatePreviousSelection(state)); pendingPromise.resolve(activatePreviousSelection(state));
return false; return;
case KEYS.SPACE: case KEYS.SPACE:
case KEYS.ENTER: case KEYS.ENTER:
// Get the item that is currently selected. // Get the item that is currently selected.
@ -855,12 +856,11 @@ function($, log, str, templates, notification, LoadingIcon) {
// Unselect this item. // Unselect this item.
pendingPromise.resolve(deselectItem(options, state, selectedItem, originalSelect)); pendingPromise.resolve(deselectItem(options, state, selectedItem, originalSelect));
} }
return false; return;
} }
// Not handled. Resolve the promise. // Not handled. Resolve the promise.
pendingPromise.resolve(); pendingPromise.resolve();
return true;
}); });
// Whenever the input field changes, update the suggestion list. // Whenever the input field changes, update the suggestion list.
if (options.showSuggestions) { if (options.showSuggestions) {