Skip to content

Commit

Permalink
feat: [select-refacto] - related #384 - improve accessiblity (ARIA ta…
Browse files Browse the repository at this point in the history
…gs), add zIndex prop (group-options), styling focus on error puik-input-wrapper
  • Loading branch information
mattgoud committed Nov 21, 2024
1 parent 301ab81 commit 2a9aebe
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion packages/components/select/src/group-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import '@prestashopcorp/puik-components/group-options/style/css';
import type GroupOptions from './group-options.vue';

export interface GroupOptionsProps {
open?: boolean
zIndex?: number
}

export type GroupOptionsInstance = InstanceType<typeof GroupOptions>;
6 changes: 2 additions & 4 deletions packages/components/select/src/group-options.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div>
<div :style="{ 'z-index': props.zIndex }">
<slot />
</div>
</template>
Expand All @@ -11,10 +11,8 @@ defineOptions({
});
const props = withDefaults(defineProps<GroupOptionsProps>(), {
open: true
zIndex: 100
});
console.log(props);
</script>

<style lang="scss">
Expand Down
3 changes: 3 additions & 0 deletions packages/components/select/src/option.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
{ 'puik-option-single--selected' : isSelectedRef && !props.multiSelect},
{ 'puik-option--disabled' : props.disabled },
]"
role="option"
:aria-selected="isSelectedRef"
:aria-disabled="props.disabled"
@click="selectOption"
>
<template v-if="props.multiSelect">
Expand Down
2 changes: 1 addition & 1 deletion packages/components/select/src/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import '@prestashopcorp/puik-components/select/style/css';
import type Select from './select.vue';
import type { OptionType } from './option';
export interface SelectProps {
id?: string
id: string
label?: string
required?: boolean
optional?: boolean
Expand Down
13 changes: 5 additions & 8 deletions packages/components/select/src/select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
<div
v-on-click-outside="closeOptions"
class="puik-select"
role="listbox"
:aria-multiselectable="props.multiSelect"
@keydown.esc="closeOptions"
>
<div
Expand All @@ -29,9 +27,11 @@
:id="props.id"
:class="['puik-multi-select__options-tags']"
tabindex="0"
:autocomplete="props.autocomplete"
role="combobox"
:aria-expanded="openRef"
:aria-controls="`dropdown-${props.id}`"
aria-haspopup="listbox"
:value="JSON.stringify(selectedMultipleOptions)"
@click.stop="toggleOptions"
@keydown.space.prevent.stop="toggleOptions"
Expand Down Expand Up @@ -71,6 +71,7 @@
role="combobox"
:aria-expanded="openRef"
:aria-controls="`dropdown-${props.id}`"
aria-haspopup="listbox"
@click.stop="toggleOptions"
@keydown.space.prevent.stop="toggleOptions"
@keydown.enter.prevent.stop="toggleOptions"
Expand Down Expand Up @@ -103,6 +104,7 @@
role="combobox"
:aria-expanded="openRef"
:aria-controls="`dropdown-${props.id}`"
aria-haspopup="listbox"
@click.stop="toggleOptions"
@keydown.space.prevent.stop="toggleOptions"
@keydown.enter.prevent.stop="toggleOptions"
Expand All @@ -117,6 +119,7 @@
:id="`dropdown-${props.id}`"
class="puik-select-dropdown"
role="listbox"
:aria-multiselectable="props.multiSelect"
>
<puik-input
v-if="searchable"
Expand Down Expand Up @@ -162,12 +165,6 @@
:option="option"
:disabled="option[props.optionDisabledKey]"
:multi-select="props.multiSelect"
role="option"
:aria-selected="
props.multiSelect
? selectedMultipleOptions.includes(option)
: selectedSingleOption === option
"
@select="selectOption(option)"
@close="closeOptions"
/>
Expand Down
3 changes: 3 additions & 0 deletions packages/theme/src/puik-select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
&:hover{
@apply border border-red;
}
&--focus {
@apply ring-4;
}
}
}
.puik-select__container--error {
Expand Down

0 comments on commit 2a9aebe

Please sign in to comment.