Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issues with rating component #3192

Merged
merged 4 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/ui/src/components/va-rating/VaRating.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
:key="itemNumber"
class="va-rating__item"
v-bind="VaRatingItemProps"
:aria-label="t('voteRating', { max: $props.max, value: $props.modelValue })"
:aria-label="t('voteRating', { max: $props.max, value: itemNumber })"
:model-value="getItemValue(itemNumber - 1)"
:tabindex="tabIndexComputed"
:disabled="$props.disabled"
Expand Down Expand Up @@ -95,7 +95,15 @@ export default defineComponent({
tabIndexComputed: computed(() => isInteractionsEnabled.value ? 0 : undefined),
onArrowKeyPress: (direction: 1 | -1) => {
const step = props.halves ? RatingValue.HALF : RatingValue.FULL
rating.onItemValueUpdate(rating.visibleValue.value, step * direction)
const nextStep = rating.visibleValue.value + step * direction
const min = props.clearable ? 0 : step
if (nextStep >= min && nextStep <= props.max) {
rating.onItemValueUpdate(rating.visibleValue.value, step * direction)
} else if (nextStep < min) {
rating.onItemValueUpdate(min, 0)
} else {
rating.onItemValueUpdate(props.max, direction === -1 ? step * direction : 0)
}
},
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
role="button"
class="va-rating-item"
:tabindex="tabIndexComputed"
@keyup.enter="onClick"
@keyup.space="onClick"
@keydown.enter="onClick"
@keydown.space.prevent="onClick"
@mousemove="onMouseMove"
@mouseleave="onMouseLeave"
@click="onClick"
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/services/i18n/config/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const getI18nConfigDefaults = () => ({
/** Rating aria-label */
currentRating: 'current rating {value} of {max}',
/** Rating item aria-label */
voteRating: '`vote rating {value} of {max}`',
voteRating: 'vote rating {value} of {max}',
/** Select search input aria-label */
optionsFilter: 'options filter',
splitPanels: 'split panels',
Expand Down