Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure shift+home and shift+end works as expected in the Combobox.Input component #2024

Merged
merged 2 commits into from Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/@headlessui-react/CHANGELOG.md
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Reset form-like components when the parent `<form>` resets ([#2004](https://github.com/tailwindlabs/headlessui/pull/2004))
- Add warning when using `<Popover.Button />` multiple times ([#2007](https://github.com/tailwindlabs/headlessui/pull/2007))
- Ensure Popover doesn't crash when `focus` is going to `window` ([#2019](https://github.com/tailwindlabs/headlessui/pull/2019))
- Ensure `shift+home` and `shift+end` works as expected in the `Combobox.Input` component ([#2024](https://github.com/tailwindlabs/headlessui/pull/2024))

## [1.7.4] - 2022-11-03

Expand Down
16 changes: 16 additions & 0 deletions packages/@headlessui-react/src/components/combobox/combobox.tsx
Expand Up @@ -817,12 +817,28 @@ let Input = forwardRefWithAs(function Input<
})

case Keys.Home:
if (event.shiftKey) {
break
}

event.preventDefault()
event.stopPropagation()
return actions.goToOption(Focus.First)

case Keys.PageUp:
event.preventDefault()
event.stopPropagation()
return actions.goToOption(Focus.First)

case Keys.End:
if (event.shiftKey) {
break
}

event.preventDefault()
event.stopPropagation()
return actions.goToOption(Focus.Last)

case Keys.PageDown:
event.preventDefault()
event.stopPropagation()
Expand Down
1 change: 1 addition & 0 deletions packages/@headlessui-vue/CHANGELOG.md
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Reset form-like components when the parent `<form>` resets ([#2004](https://github.com/tailwindlabs/headlessui/pull/2004))
- Ensure Popover doesn't crash when `focus` is going to `window` ([#2019](https://github.com/tailwindlabs/headlessui/pull/2019))
- Ensure `shift+home` and `shift+end` works as expected in the `ComboboxInput` component ([#2024](https://github.com/tailwindlabs/headlessui/pull/2024))

## [1.7.4] - 2022-11-03

Expand Down
16 changes: 16 additions & 0 deletions packages/@headlessui-vue/src/components/combobox/combobox.ts
Expand Up @@ -775,12 +775,28 @@ export let ComboboxInput = defineComponent({
})

case Keys.Home:
if (event.shiftKey) {
break
}

event.preventDefault()
event.stopPropagation()
return api.goToOption(Focus.First)

case Keys.PageUp:
event.preventDefault()
event.stopPropagation()
return api.goToOption(Focus.First)

case Keys.End:
if (event.shiftKey) {
break
}

event.preventDefault()
event.stopPropagation()
return api.goToOption(Focus.Last)

case Keys.PageDown:
event.preventDefault()
event.stopPropagation()
Expand Down