Skip to content

Commit

Permalink
fix(Select, Combobox): prevent override default boolean prop value wi…
Browse files Browse the repository at this point in the history
…th useForwardProps (#610)

* fix: prevent override default prop value with useForwardProps

* fix: update

* fix: forwardProps in `ComboboxContentImpl.vue`
  • Loading branch information
sadeghbarati committed Jan 16, 2024
1 parent 9627e2d commit cd33af8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
5 changes: 4 additions & 1 deletion packages/radix-vue/src/Combobox/ComboboxContentImpl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Ref } from 'vue'
import {
createContext,
useBodyScrollLock,
useForwardProps,
useHideOthers,
} from '@/shared'
Expand Down Expand Up @@ -56,6 +57,8 @@ const pickedProps = computed(() => {
else return {}
})
const forwardedProps = useForwardProps(pickedProps.value)
function handleLeave(ev: PointerEvent) {
rootContext.onSelectedValueChange('')
}
Expand Down Expand Up @@ -102,7 +105,7 @@ provideComboboxContentContext({ position })
>
<component
:is="position === 'popper' ? PopperContent : Primitive "
v-bind="{ ...$attrs, ...pickedProps }"
v-bind="{ ...$attrs, ...forwardedProps }"
:id="rootContext.contentId"
ref="primitiveElement"
role="listbox"
Expand Down
6 changes: 2 additions & 4 deletions packages/radix-vue/src/Select/SelectContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ defineOptions({
inheritAttrs: false,
})
const props = withDefaults(defineProps<SelectContentProps>(), {
align: 'start',
position: 'item-aligned',
})
const props = defineProps<SelectContentProps>()
const emits = defineEmits<SelectContentEmits>()
const forwarded = useForwardPropsEmits(props, emits)
Expand Down
10 changes: 8 additions & 2 deletions packages/radix-vue/src/Select/SelectContentImpl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
useBodyScrollLock,
useCollection,
useFocusGuards,
useForwardProps,
useHideOthers,
useTypeahead,
} from '@/shared'
Expand Down Expand Up @@ -80,7 +81,10 @@ import { FocusScope } from '@/FocusScope'
import { DismissableLayer } from '@/DismissableLayer'
import { focusFirst } from '@/Menu/utils'
const props = defineProps<SelectContentImplProps>()
const props = withDefaults(defineProps<SelectContentImplProps>(), {
align: 'start',
position: 'item-aligned',
})
const emits = defineEmits<SelectContentImplEmits>()
const rootContext = injectSelectRootContext()
Expand Down Expand Up @@ -190,6 +194,8 @@ const pickedProps = computed(() => {
else return {}
})
const forwardedProps = useForwardProps(pickedProps.value)
provideSelectContentContext({
content,
viewport,
Expand Down Expand Up @@ -254,7 +260,7 @@ provideSelectContentContext({
? SelectPopperPosition
: SelectItemAlignedPosition
"
v-bind="{ ...$attrs, ...pickedProps }"
v-bind="{ ...$attrs, ...forwardedProps }"
:id="rootContext.contentId"
:ref="
(vnode: ComponentPublicInstance) => {
Expand Down

0 comments on commit cd33af8

Please sign in to comment.