Skip to content

Commit

Permalink
Merge pull request #1041 from PrefectHQ/fix-select-option-groups
Browse files Browse the repository at this point in the history
Fix select option groups
  • Loading branch information
pleek91 authored Dec 8, 2023
2 parents df43d9f + 769157e commit 13d23dc
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/components/Select/PSelectOptions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@mouseleave="setHighlightedValueUnselected"
>
<slot name="pre-options" />
<PVirtualScroller :items="flattened" item-key="label" class="p-select-options__options" @bottom="emit('bottom')">
<PVirtualScroller :items="flattenedOptionsAndGroups" item-key="label" class="p-select-options__options" @bottom="emit('bottom')">
<template #default="{ item: option, index }">
<template v-if="isSelectOptionGroup(option)">
<PSelectOptionGroup :group="option">
Expand Down Expand Up @@ -118,9 +118,10 @@
internalValue.value = newValue
}
const flatSelectOptions = computed(() => flattenSelectOptions(props.options.map(normalizeSelectOption)))
const flattened = computed(() => flatSelectOptions.value.flatMap(option => flattenGroupsAndOptions(option)))
const { highlightedValue, isUnselected, setHighlightedValueUnselected, setNextHighlightedValue, setPreviousHighlightedValue } = useHighlightedValue(flatSelectOptions)
const normalized = props.options.map(option => normalizeSelectOption(option))
const flattenedOptionsAndGroups = computed(() => normalized.flatMap(option => flattenGroupsAndOptions(option)))
const flattenedOptions = computed(() => flattenSelectOptions(normalized))
const { highlightedValue, isUnselected, setHighlightedValueUnselected, setNextHighlightedValue, setPreviousHighlightedValue } = useHighlightedValue(flattenedOptions)
useKeyDown(['ArrowDown', 'ArrowUp', ' ', 'Enter'], onKeyDown)
Expand Down

0 comments on commit 13d23dc

Please sign in to comment.