From d1ef18e6f9ed1527b66cec07eba6acaf9a95819c Mon Sep 17 00:00:00 2001
From: Paul Fertser <fercerpav@gmail.com>
Date: Sat, 6 Apr 2024 08:04:14 +0000
Subject: 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>
---
 src/views/Operations/KeyClear/KeyClear.vue | 1 +
 1 file changed, 1 insertion(+)

(limited to 'src/views/Operations/KeyClear/KeyClear.vue')

diff --git a/src/views/Operations/KeyClear/KeyClear.vue b/src/views/Operations/KeyClear/KeyClear.vue
index 2524da10..fbdf4c46 100644
--- a/src/views/Operations/KeyClear/KeyClear.vue
+++ b/src/views/Operations/KeyClear/KeyClear.vue
@@ -91,6 +91,7 @@ export default {
           okTitle: this.$t('pageKeyClear.modal.clear'),
           okVariant: 'danger',
           cancelTitle: this.$t('global.action.cancel'),
+          autoFocusButton: 'cancel',
         })
         .then((clearConfirmed) => {
           if (clearConfirmed) {
-- 
cgit v1.2.3

