Focus default action in modal windows
Users of common WIMP GUIs (as opposed to interfaces primarily meant for
touch input) expect dialog boxes to have keyboard focus set on the
button for default action so that it can be executed by a single key
press. Usually that is chosen to proceed with the operation but in cases
where that leads to data loss the UI designers often pre-select Cancel
as a precaution.
This patch adds suitable property to all invocations of msgBoxConfirm()
method of `this.$bvModal` BootstrapVue object. For regular actions the
confirmation button is selected and can be activated by Enter or Space
bar. For actions deemed dangerous Cancel is focused instead so it takes
two key presses (first being Tab to shift the focus) to prooceed.
This also improves accessibility following the Web Content Accessibility
Guidelines (WCAG) published by W3C.
Tested: manually verified that modals are consistently shown with the
specified button focused, Enter and Space bar key presses produce the
same effect as left pointer button click: when Cancel is focused it just
closes the window, when OK is focused it sends the corresponding request
to the Redfish endpoint.
Change-Id: I66bfd02e48e08dc18994b11bbdd5d6b3ea27047f
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
diff --git a/src/views/Operations/ServerPowerOperations/ServerPowerOperations.vue b/src/views/Operations/ServerPowerOperations/ServerPowerOperations.vue
index e3864b4..281bbef 100644
--- a/src/views/Operations/ServerPowerOperations/ServerPowerOperations.vue
+++ b/src/views/Operations/ServerPowerOperations/ServerPowerOperations.vue
@@ -219,6 +219,7 @@
title: this.$t('pageServerPowerOperations.modal.confirmRebootTitle'),
okTitle: this.$t('global.action.confirm'),
cancelTitle: this.$t('global.action.cancel'),
+ autoFocusButton: 'ok',
};
if (this.form.rebootOption === 'orderly') {
@@ -243,6 +244,7 @@
title: this.$t('pageServerPowerOperations.modal.confirmShutdownTitle'),
okTitle: this.$t('global.action.confirm'),
cancelTitle: this.$t('global.action.cancel'),
+ autoFocusButton: 'ok',
};
if (this.form.shutdownOption === 'orderly') {