Skip to content

Commit

Permalink
Focus default action in modal windows
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
paulfertser authored and Gunnar Mills committed Apr 18, 2024
1 parent f820774 commit d1ef18e
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/guide/guidelines/internationalization.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,6 @@ this.$bvModal
title: this.$tc('pageDumps.modal.deleteDump'),
okTitle: this.$tc('pageDumps.modal.deleteDump'),
cancelTitle: this.$t('global.action.cancel'),
autoFocusButton: 'ok',
})
```
2 changes: 2 additions & 0 deletions src/views/Logs/Dumps/Dumps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ export default {
title: this.$tc('pageDumps.modal.deleteDump'),
okTitle: this.$tc('pageDumps.modal.deleteDump'),
cancelTitle: this.$t('global.action.cancel'),
autoFocusButton: 'ok',
})
.then((deleteConfrimed) => {
if (deleteConfrimed) {
Expand Down Expand Up @@ -368,6 +369,7 @@ export default {
this.selectedRows.length,
),
cancelTitle: this.$t('global.action.cancel'),
autoFocusButton: 'ok',
},
)
.then((deleteConfrimed) => {
Expand Down
3 changes: 3 additions & 0 deletions src/views/Logs/EventLogs/EventLogs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ export default {
okTitle: this.$t('global.action.delete'),
okVariant: 'danger',
cancelTitle: this.$t('global.action.cancel'),
autoFocusButton: 'cancel',
})
.then((deleteConfirmed) => {
if (deleteConfirmed) {
Expand Down Expand Up @@ -535,6 +536,7 @@ export default {
title: this.$tc('pageEventLogs.modal.deleteTitle'),
okTitle: this.$t('global.action.delete'),
cancelTitle: this.$t('global.action.cancel'),
autoFocusButton: 'ok',
})
.then((deleteConfirmed) => {
if (deleteConfirmed) this.deleteLogs([uri]);
Expand All @@ -557,6 +559,7 @@ export default {
),
okTitle: this.$t('global.action.delete'),
cancelTitle: this.$t('global.action.cancel'),
autoFocusButton: 'ok',
},
)
.then((deleteConfirmed) => {
Expand Down
1 change: 1 addition & 0 deletions src/views/Logs/PostCodeLogs/PostCodeLogs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ export default {
okTitle: this.$t('global.action.delete'),
okVariant: 'danger',
cancelTitle: this.$t('global.action.cancel'),
autoFocusButton: 'cancel',
})
.then((deleteConfirmed) => {
if (deleteConfirmed) {
Expand Down
1 change: 1 addition & 0 deletions src/views/Operations/KeyClear/KeyClear.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/views/Operations/RebootBmc/RebootBmc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export default {
title: this.$t('pageRebootBmc.modal.confirmTitle'),
okTitle: this.$t('global.action.confirm'),
cancelTitle: this.$t('global.action.cancel'),
autoFocusButton: 'ok',
})
.then((confirmed) => {
if (confirmed) this.rebootBmc();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ export default {
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') {
Expand All @@ -243,6 +244,7 @@ export default {
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') {
Expand Down
1 change: 1 addition & 0 deletions src/views/SecurityAndAccess/Certificates/Certificates.vue
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ export default {
title: this.$t('pageCertificates.deleteCertificate'),
okTitle: this.$t('global.action.delete'),
cancelTitle: this.$t('global.action.cancel'),
autoFocusButton: 'ok',
},
)
.then((deleteConfirmed) => {
Expand Down
2 changes: 2 additions & 0 deletions src/views/SecurityAndAccess/Ldap/TableRoleGroups.vue
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export default {
title: this.$t('pageLdap.modal.deleteRoleGroup'),
okTitle: this.$t('global.action.delete'),
cancelTitle: this.$t('global.action.cancel'),
autoFocusButton: 'ok',
},
)
.then((deleteConfirmed) => {
Expand Down Expand Up @@ -227,6 +228,7 @@ export default {
title: this.$t('pageLdap.modal.deleteRoleGroup'),
okTitle: this.$t('global.action.delete'),
cancelTitle: this.$t('global.action.cancel'),
autoFocusButton: 'ok',
},
)
.then((deleteConfirmed) => {
Expand Down
2 changes: 2 additions & 0 deletions src/views/SecurityAndAccess/Sessions/Sessions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ export default {
title: this.$tc('pageSessions.modal.disconnectTitle'),
okTitle: this.$t('pageSessions.action.disconnect'),
cancelTitle: this.$t('global.action.cancel'),
autoFocusButton: 'ok',
})
.then((deleteConfirmed) => {
if (deleteConfirmed) this.disconnectSessions([uri]);
Expand All @@ -283,6 +284,7 @@ export default {
),
okTitle: this.$t('pageSessions.action.disconnect'),
cancelTitle: this.$t('global.action.cancel'),
autoFocusButton: 'ok',
},
)
.then((deleteConfirmed) => {
Expand Down
2 changes: 2 additions & 0 deletions src/views/SecurityAndAccess/UserManagement/UserManagement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ export default {
title: this.$tc('pageUserManagement.deleteUser'),
okTitle: this.$tc('pageUserManagement.deleteUser'),
cancelTitle: this.$t('global.action.cancel'),
autoFocusButton: 'ok',
},
)
.then((deleteConfirmed) => {
Expand Down Expand Up @@ -329,6 +330,7 @@ export default {
this.selectedRows.length,
),
cancelTitle: this.$t('global.action.cancel'),
autoFocusButton: 'ok',
},
)
.then((deleteConfirmed) => {
Expand Down
1 change: 1 addition & 0 deletions src/views/Settings/Network/TableIpv4.vue
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ export default {
: this.$t('global.action.disable'),
okVariant: 'danger',
cancelTitle: this.$t('global.action.cancel'),
autoFocusButton: 'cancel',
},
)
.then((dhcpEnableConfirmed) => {
Expand Down
2 changes: 2 additions & 0 deletions src/views/Settings/SnmpAlerts/SnmpAlerts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ export default {
title: this.$tc('pageSnmpAlerts.modal.deleteSnmpDestinationTitle'),
okTitle: this.$tc('pageSnmpAlerts.deleteDestination'),
cancelTitle: this.$t('global.action.cancel'),
autoFocusButton: 'ok',
},
)
.then((deleteConfirmed) => {
Expand Down Expand Up @@ -243,6 +244,7 @@ export default {
this.selectedRows.length,
),
cancelTitle: this.$t('global.action.cancel'),
autoFocusButton: 'ok',
},
)
.then((deleteConfirmed) => {
Expand Down

0 comments on commit d1ef18e

Please sign in to comment.