From 13496483fe222f3f3ac1cb96fb15a108b2e47bdb Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Fri, 24 Jan 2025 09:33:00 +0000 Subject: [PATCH] keyboard navigation for cluster badge appearance modal (#13021) * working on key nav for cluster badge appearance * color input is now key nav friendly + tooltip works on focus + trying to get focus trap to work properly * remove console logs + add focus trap to card component with prop control + fix element for config badge button * fix lint problem * fix TS errors on pkg build * remove step of building the skeleton app in the check-plugins-build step, which imo doesnt serve any purpose whatsoever * add focus-trap as a shell dependency + revert publish script change * remove focus-trap directive + improve chaining event handler modifiers * pin focus-trap to 7.6.2 + replace link for button on cluster explorer main page + remove unused ev * address pr comments --- package.json | 5 ++-- .../src/components/Card/Card.vue | 28 ++++++++++++++++++- .../src/components/Form/Checkbox/Checkbox.vue | 11 ++++++-- shell/assets/styles/global/_button.scss | 5 ++++ shell/assets/translations/en-us.yaml | 1 + shell/components/Tabbed/index.vue | 13 ++++++++- shell/components/form/ColorInput.vue | 25 ++++++++++++++++- shell/dialog/AddCustomBadgeDialog.vue | 6 +++- shell/package.json | 1 + .../pages/c/_cluster/explorer/ConfigBadge.vue | 15 +++++----- shell/pages/c/_cluster/explorer/index.vue | 19 +++++++++---- shell/scripts/test-plugins-build.sh | 2 ++ shell/yarn.lock | 12 ++++++++ yarn.lock | 13 +++++++++ 14 files changed, 135 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index 81f7fd79d57..24f45bdc8a2 100644 --- a/package.json +++ b/package.json @@ -90,6 +90,7 @@ "express": "4.17.1", "file-saver": "2.0.2", "floating-vue": "5.2.2", + "focus-trap": "7.6.2", "https": "1.0.0", "identicon.js": "2.3.3", "intl-messageformat": "7.8.4", @@ -178,6 +179,7 @@ "eslint-plugin-cypress": "2.12.1", "eslint-plugin-import": "2.31.0", "eslint-plugin-jest": "24.4.0", + "eslint-plugin-local-rules": "link:./eslint-plugin-local-rules", "eslint-plugin-node": "11.1.0", "eslint-plugin-vue": "9.10.0", "eslint": "7.32.0", @@ -197,8 +199,7 @@ "webpack-virtual-modules": "0.4.3", "worker-loader": "3.0.8", "yaml-lint": "1.7.0", - "yarn": "1.22.18", - "eslint-plugin-local-rules": "link:./eslint-plugin-local-rules" + "yarn": "1.22.18" }, "resolutions": { "html-webpack-plugin": "^5.0.0" diff --git a/pkg/rancher-components/src/components/Card/Card.vue b/pkg/rancher-components/src/components/Card/Card.vue index bb39c93bb0f..f7e7790dd41 100644 --- a/pkg/rancher-components/src/components/Card/Card.vue +++ b/pkg/rancher-components/src/components/Card/Card.vue @@ -1,5 +1,6 @@ @@ -329,6 +331,11 @@ $fontColor: var(--input-label); .checkbox-info { line-height: normal; margin-left: 2px; + + &:focus-visible { + @include focus-outline; + outline-offset: 2px; + } } .checkbox-custom { diff --git a/shell/assets/styles/global/_button.scss b/shell/assets/styles/global/_button.scss index cd193b84474..d516dfc5678 100644 --- a/shell/assets/styles/global/_button.scss +++ b/shell/assets/styles/global/_button.scss @@ -141,6 +141,11 @@ button, color: var(--link); box-shadow: none; } + + &:focus-visible { + @include focus-outline; + outline-offset: 2px; + } } .role-multi-action { diff --git a/shell/assets/translations/en-us.yaml b/shell/assets/translations/en-us.yaml index 4e87c7066bb..601afe57ea5 100644 --- a/shell/assets/translations/en-us.yaml +++ b/shell/assets/translations/en-us.yaml @@ -9,6 +9,7 @@ generic: back: Back cancel: Cancel confirm: Confirm + colorPicker: Color picker clear: Clear clearAll: Clear All close: Close diff --git a/shell/components/Tabbed/index.vue b/shell/components/Tabbed/index.vue index 7c3a5be5def..25eb101fe3f 100644 --- a/shell/components/Tabbed/index.vue +++ b/shell/components/Tabbed/index.vue @@ -258,7 +258,6 @@ export default { role="tablist" class="tabs" :class="{'clearfix':!sideTabs, 'vertical': sideTabs, 'horizontal': !sideTabs}" - tabindex="0" data-testid="tabbed-block" @keydown.right.prevent="selectNext(1)" @keydown.left.prevent="selectNext(-1)" @@ -277,8 +276,12 @@ export default { :data-testid="`btn-${tab.name}`" :aria-controls="'#' + tab.name" :aria-selected="tab.active" + :aria-label="tab.labelDisplay" role="tab" + tabindex="0" @click.prevent="select(tab.name, $event)" + @keyup.enter="select(tab.name, $event)" + @keyup.space="select(tab.name, $event)" > {{ tab.labelDisplay }} @@ -82,6 +96,8 @@ export default { class="color-input" :class="{[mode]:mode, disabled: isDisabled}" :data-testid="componentTestid + '-color-input'" + :tabindex="isDisabled ? -1 : 0" + @keyup.enter.space.stop="handleKeyup($event)" >