Skip to content

Commit

Permalink
fix key nav on charts page in cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
aalves08 committed Jan 16, 2025
1 parent 0cd9bff commit 2f2591a
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 52 deletions.
5 changes: 5 additions & 0 deletions shell/assets/styles/global/_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ fieldset[disabled] .btn {
z-index: 1;
}

&:focus-visible {
z-index: 1;
@include focus-outline;
}

&.active {
@extend .bg-primary;
}
Expand Down
1 change: 1 addition & 0 deletions shell/assets/styles/vendor/vue-select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
color: var(--dropdown-text);
white-space: nowrap;
z-index: 1000;
overflow: auto;

&:hover {
cursor: pointer;
Expand Down
8 changes: 7 additions & 1 deletion shell/assets/translations/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,7 @@ catalog:
experimentalWarning: '{chartName} has been marked as experimental. Use caution when installing this helm chart as it might not function as expected.'
deprecatedAndExperimentalWarning: '{chartName} has been marked as deprecated and experimental. Use caution when installing this helm chart as it might be removed in the future and might not function as expected.'
charts:
refresh: refresh charts
all: All
categories:
all: All Categories
Expand All @@ -950,7 +951,7 @@ catalog:
all: All Operating Systems
linux: Linux
windows: Windows
search: Filter
search: Filter charts results
deprecatedChartsFilter:
label: Show deprecated apps
install:
Expand Down Expand Up @@ -6129,6 +6130,11 @@ validation:
interval: '"{key}" must be of a format with digits followed by a unit i.e. 1h, 2m, 30s'
tab: "One or more fields in this tab contain a form validation error"

carousel:
previous: Previous
next: Next
controlItem: Go to slide nº {number}

wizard:
previous: Previous
finish: Finish
Expand Down
2 changes: 2 additions & 0 deletions shell/components/ButtonGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ export default {
type="button"
:class="opt.class"
:disabled="disabled || opt.disabled"
role="button"
:aria-label="opt.labelKey ? t(opt.labelKey) : opt.label"
@click="change(opt.value)"
>
<slot
Expand Down
65 changes: 36 additions & 29 deletions shell/components/Carousel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -195,33 +195,51 @@ export default {
</div>
</component>
</div>
<div
class="controls"
:class="{'disable': sliders.length === 1}"
>
<div
v-for="(slide, i) in slider"
:key="i"
class="control-item"
:class="{'active': activeItemId === i}"
@click="scrollSlide(i, slider.length)"
/>
</div>
<div
ref="prev"
role="button"
class="prev"
:aria-label="t('carousel.previous')"
:aria-disabled="sliders.length === 1"
:class="{'disable': sliders.length === 1}"
tabindex="0"
@click="nextPrev('prev')"
@keyup.enter.space="nextPrev('prev')"
>
<i class="icon icon-chevron-left icon-4x" />
<i
class="icon icon-chevron-left icon-4x"
/>
</div>
<div
ref="next"
role="button"
class="next"
:aria-label="t('carousel.next')"
:aria-disabled="sliders.length === 1"
:class="{'disable': sliders.length === 1}"
tabindex="0"
@click="nextPrev('next')"
@keyup.enter.space="nextPrev('next')"
>
<i
class="icon icon-chevron-right icon-4x"
/>
</div>
<div
class="controls"
:class="{'disable': sliders.length === 1}"
>
<i class="icon icon-chevron-right icon-4x" />
<div
v-for="(slide, i) in slider"
:key="i"
class="control-item"
:class="{'active': activeItemId === i}"
role="button"
tabindex="0"
:aria-label="t('carousel.controlItem', { number: i+1 })"
@click="scrollSlide(i, slider.length)"
@keyup.enter.space="scrollSlide(i, slider.length)"
/>
</div>
</div>
</template>
Expand All @@ -240,20 +258,6 @@ export default {
&.disable::after {
display: none;
}
&.disable:hover {
.prev,
.next {
display: none;
}
}
&:hover {
.prev,
.next {
display: block;
}
}
}
.slide-track {
Expand Down Expand Up @@ -367,13 +371,16 @@ export default {
position: absolute;
z-index: 20;
top: 90px;
display: none;
cursor: pointer;
&.disabled .icon {
color: var(--disabled-bg);
cursor: not-allowed;
}
.icon:focus-visible {
@include focus-outline;
}
}
.next {
Expand Down
13 changes: 12 additions & 1 deletion shell/components/SelectIconGrid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,23 @@ export default {
:is="asLink ? 'a' : 'div'"
v-for="(r, idx) in rows"
:key="get(r, keyField)"
:role="asLink ? 'link' : null"
:aria-disabled="asLink && get(r, disabledField) === true ? true : null"
:aria-label="get(r, nameField)"
:tabindex="get(r, disabledField) === true ? -1 : 0"
:href="asLink ? get(r, linkField) : null"
:target="get(r, targetField)"
:rel="rel"
class="item"
:data-testid="componentTestid + '-' + get(r, nameField)"
:class="{
'has-description': !!get(r, descriptionField),
'has-side-label': !!get(r, sideLabelField), [colorFor(r, idx)]: true, disabled: get(r, disabledField) === true
'has-side-label': !!get(r, sideLabelField),
[colorFor(r, idx)]: true,
disabled: get(r, disabledField) === true
}"
@click="select(r, idx)"
@keyup.enter.space="select(r, idx)"
>
<div
class="side-label"
Expand Down Expand Up @@ -212,6 +219,10 @@ export default {
text-decoration: none !important;
color: $color;
&:focus-visible {
@include focus-outline;
}
&:hover:not(.disabled) {
box-shadow: 0 0 30px var(--shadow);
transition: box-shadow 0.1s ease-in-out;
Expand Down
36 changes: 31 additions & 5 deletions shell/components/form/Select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,24 @@ export default {
calculatePosition(dropdownList, component, width, this.placement);
},
focus() {
this.focusSearch();
},
focusSearch() {
// we need this override as in a "closeOnSelect" type of component
// if we don't have this override, it would open again
if (this.overridesMixinPreventDoubleTriggerKeysOpen) {
this.$nextTick(() => {
const el = this.$refs['select'];
if ( el ) {
el.focus();
}
this.overridesMixinPreventDoubleTriggerKeysOpen = false;
});
return;
}
this.$refs['select-input'].open = true;
this.$nextTick(() => {
const el = this.$refs['select-input']?.searchEl;
Expand Down Expand Up @@ -176,6 +189,11 @@ export default {
},
report(e) {
alert(e);
},
handleDropdownOpen(args) {
// function that prevents the "opening dropdown on focus"
// default behaviour of v-select
return args.noDrop || args.disabled ? false : args.open;
}
},
computed: {
Expand Down Expand Up @@ -236,7 +254,9 @@ export default {
'compact-input': compact,
[$attrs.class]: $attrs.class
}"
@focus="focusSearch"
:tabindex="disabled ? -1 : 0"
@click="focusSearch"
@keyup.enter.space.down="focusSearch"
>
<v-select
ref="select-input"
Expand All @@ -258,6 +278,8 @@ export default {
:searchable="isSearchable"
:selectable="selectable"
:modelValue="value != null ? value : ''"
:dropdownShouldOpen="handleDropdownOpen"
:tabindex="-1"
@update:modelValue="$emit('update:value', $event)"
@search:blur="onBlur"
Expand Down Expand Up @@ -300,6 +322,10 @@ export default {
.unlabeled-select {
position: relative;
&:focus-visible {
@include focus-outline;
}
:deep() .v-select.select-input-view {
.vs__actions {
visibility: hidden;
Expand Down
26 changes: 10 additions & 16 deletions shell/mixins/vue-select-overrides.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@

export default {
data() {
return { overridesMixinPreventDoubleTriggerKeysOpen: false };
},
methods: {
mappedKeys(map, vm) {
// Defaults found at - https://github.com/sagalbot/vue-select/blob/master/src/components/Select.vue#L947
Expand All @@ -13,31 +16,19 @@ export default {
}

e.preventDefault();

const optsLen = vm.filteredOptions.length;
const typeAheadPointer = vm.typeAheadPointer;

if (e.shiftKey) {
if (typeAheadPointer === 0) {
return vm.onEscape();
}

return vm.typeAheadUp();
}
if (typeAheadPointer + 1 === optsLen) {
return vm.onEscape();
}

return vm.typeAheadDown();
});

// escape
(out[27] = (e) => {
vm.open = false;
vm.search = '';

this.$refs.select.focus();

return false;
});

// enter
(out[13] = (e, opt) => {
if (!vm.open) {
vm.open = true;
Expand All @@ -60,6 +51,9 @@ export default {
vm.$emit('option:selected', option);

if (vm.closeOnSelect) {
// this ties in to the Select component implementation
// so that the enter key handler doesn't open the dropdown again
this.overridesMixinPreventDoubleTriggerKeysOpen = true;
vm.open = false;
vm.typeAheadPointer = -1;
}
Expand Down
4 changes: 4 additions & 0 deletions shell/pages/c/_cluster/apps/charts/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,8 @@ export default {
class="input-sm"
:placeholder="t('catalog.charts.search')"
data-testid="charts-filter-input"
:aria-label="t('catalog.charts.search')"
role="textbox"
>

<button
Expand All @@ -463,6 +465,8 @@ export default {
@shortkey="focusSearch()"
/>
<AsyncButton
role="button"
:aria-label="t('catalog.charts.refresh')"
class="refresh-btn"
mode="refresh"
size="sm"
Expand Down

0 comments on commit 2f2591a

Please sign in to comment.