Skip to content

Commit

Permalink
[vue] Fix Combobox input disabled state (#2375)
Browse files Browse the repository at this point in the history
* [vue] Fix Combobox input disabled state

* Add tests for disabled input in React and Vue

* Update changelog

---------

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
  • Loading branch information
mathieutu and thecrypticace committed Mar 16, 2023
1 parent fc9a625 commit d55c77e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,16 @@ describe('Rendering', () => {
attributes: { id: 'headlessui-combobox-button-2' },
})
assertComboboxList({ state: ComboboxState.InvisibleUnmounted })

// The input should also be disabled
assertComboboxInput({
state: ComboboxState.InvisibleUnmounted,
attributes: { id: 'headlessui-combobox-input-1', disabled: '' },
})

// And even if we try to focus it, it should not open the combobox
await focus(getComboboxInput())
assertComboboxList({ state: ComboboxState.InvisibleUnmounted })
})
)

Expand Down
1 change: 1 addition & 0 deletions packages/@headlessui-vue/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

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

### Added

Expand Down
10 changes: 10 additions & 0 deletions packages/@headlessui-vue/src/components/combobox/combobox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,16 @@ describe('Rendering', () => {
attributes: { id: 'headlessui-combobox-button-2' },
})
assertComboboxList({ state: ComboboxState.InvisibleUnmounted })

// The input should also be disabled
assertComboboxInput({
state: ComboboxState.InvisibleUnmounted,
attributes: { id: 'headlessui-combobox-input-1', disabled: '' },
})

// And even if we try to focus it, it should not open the combobox
await focus(getComboboxInput())
assertComboboxList({ state: ComboboxState.InvisibleUnmounted })
})
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,7 @@ export let ComboboxInput = defineComponent({
tabIndex: 0,
ref: api.inputRef,
defaultValue: defaultValue.value,
disabled: api.disabled.value === true ? true : undefined,
}

return render({
Expand Down

0 comments on commit d55c77e

Please sign in to comment.