Skip to content

Commit d55c77e

Browse files
[vue] Fix Combobox input disabled state (#2375)
* [vue] Fix Combobox input disabled state * Add tests for disabled input in React and Vue * Update changelog --------- Co-authored-by: Jordan Pittman <[email protected]>
1 parent fc9a625 commit d55c77e

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

packages/@headlessui-react/src/components/combobox/combobox.test.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,16 @@ describe('Rendering', () => {
169169
attributes: { id: 'headlessui-combobox-button-2' },
170170
})
171171
assertComboboxList({ state: ComboboxState.InvisibleUnmounted })
172+
173+
// The input should also be disabled
174+
assertComboboxInput({
175+
state: ComboboxState.InvisibleUnmounted,
176+
attributes: { id: 'headlessui-combobox-input-1', disabled: '' },
177+
})
178+
179+
// And even if we try to focus it, it should not open the combobox
180+
await focus(getComboboxInput())
181+
assertComboboxList({ state: ComboboxState.InvisibleUnmounted })
172182
})
173183
)
174184

packages/@headlessui-vue/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Fixed
1111

1212
- Fix focus styles showing up when using the mouse ([#2347](https://github.com/tailwindlabs/headlessui/pull/2347))
13+
- Disable `ComboboxInput` when its `Combobox` is disabled ([#2375](https://github.com/tailwindlabs/headlessui/pull/2375))
1314

1415
### Added
1516

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,16 @@ describe('Rendering', () => {
200200
attributes: { id: 'headlessui-combobox-button-2' },
201201
})
202202
assertComboboxList({ state: ComboboxState.InvisibleUnmounted })
203+
204+
// The input should also be disabled
205+
assertComboboxInput({
206+
state: ComboboxState.InvisibleUnmounted,
207+
attributes: { id: 'headlessui-combobox-input-1', disabled: '' },
208+
})
209+
210+
// And even if we try to focus it, it should not open the combobox
211+
await focus(getComboboxInput())
212+
assertComboboxList({ state: ComboboxState.InvisibleUnmounted })
203213
})
204214
)
205215

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,7 @@ export let ComboboxInput = defineComponent({
935935
tabIndex: 0,
936936
ref: api.inputRef,
937937
defaultValue: defaultValue.value,
938+
disabled: api.disabled.value === true ? true : undefined,
938939
}
939940

940941
return render({

0 commit comments

Comments
 (0)