Skip to content

Commit 807ae66

Browse files
authored
Manually passthrough attrs for Combobox, Listbox and TabsGroup component (#1372)
* manually pass through `attrs` Due to the return of the Fragment (for form compatibility) the attributes will now be pass onto this Fragment instead of the underlying DOM node. To fix this, we disable the `inheritAttrs` magic, and passthrough the attributes to the correct component. * update changelog
1 parent 97c0ca2 commit 807ae66

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
## [Unreleased - @headlessui/vue]
1313

14-
- Nothing yet!
14+
### Fixed
15+
16+
- Manually passthrough `attrs` for `Combobox`, `Listbox` and `TabsGroup` component ([#1372](https://github.com/tailwindlabs/headlessui/pull/1372))
1517

1618
## [@headlessui/react@v1.6.0] - 2022-04-25
1719

packages/@headlessui-vue/src/components/combobox/combobox.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export let Combobox = defineComponent({
115115
nullable: { type: Boolean, default: false },
116116
multiple: { type: [Boolean], default: false },
117117
},
118+
inheritAttrs: false,
118119
setup(props, { slots, attrs, emit }) {
119120
let comboboxState = ref<StateDefinition['comboboxState']['value']>(ComboboxStates.Closed)
120121
let labelRef = ref<StateDefinition['labelRef']['value']>(null)
@@ -445,7 +446,10 @@ export let Combobox = defineComponent({
445446
)
446447
: []),
447448
render({
448-
props: omit(incomingProps, ['nullable', 'multiple', 'onUpdate:modelValue']),
449+
props: {
450+
...attrs,
451+
...omit(incomingProps, ['nullable', 'multiple', 'onUpdate:modelValue']),
452+
},
449453
slot,
450454
slots,
451455
attrs,

packages/@headlessui-vue/src/components/listbox/listbox.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export let Listbox = defineComponent({
115115
name: { type: String, optional: true },
116116
multiple: { type: [Boolean], default: false },
117117
},
118+
inheritAttrs: false,
118119
setup(props, { slots, attrs, emit }) {
119120
let listboxState = ref<StateDefinition['listboxState']['value']>(ListboxStates.Closed)
120121
let labelRef = ref<StateDefinition['labelRef']['value']>(null)
@@ -328,7 +329,10 @@ export let Listbox = defineComponent({
328329
)
329330
: []),
330331
render({
331-
props: omit(incomingProps, ['onUpdate:modelValue', 'horizontal', 'multiple']),
332+
props: {
333+
...attrs,
334+
...omit(incomingProps, ['onUpdate:modelValue', 'horizontal', 'multiple']),
335+
},
332336
slot,
333337
slots,
334338
attrs,

packages/@headlessui-vue/src/components/tabs/tabs.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export let TabGroup = defineComponent({
6969
vertical: { type: [Boolean], default: false },
7070
manual: { type: [Boolean], default: false },
7171
},
72+
inheritAttrs: false,
7273
setup(props, { slots, attrs, emit }) {
7374
let selectedIndex = ref<StateDefinition['selectedIndex']['value']>(null)
7475
let tabs = ref<StateDefinition['tabs']['value']>([])
@@ -152,7 +153,10 @@ export let TabGroup = defineComponent({
152153
},
153154
}),
154155
render({
155-
props: omit(props, ['selectedIndex', 'defaultIndex', 'manual', 'vertical', 'onChange']),
156+
props: {
157+
...attrs,
158+
...omit(props, ['selectedIndex', 'defaultIndex', 'manual', 'vertical', 'onChange']),
159+
},
156160
slot,
157161
slots,
158162
attrs,

0 commit comments

Comments
 (0)