Skip to content

Commit a7154dc

Browse files
authored
Remove leftover code in Combobox component (#1514)
* remove leftover code This code existed before we had the option to make the first option the "active" one. This also contains a bug in the React code where pressing "ArrowDown" in a closed Combobox opens the combobox and goes to the second item instead of the first option. * update changelog
1 parent eefc03c commit a7154dc

File tree

3 files changed

+3
-44
lines changed

3 files changed

+3
-44
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
### Fixed
1616

1717
- Ensure `Escape` propagates correctly in `Combobox` component ([#1511](https://github.com/tailwindlabs/headlessui/pull/1511))
18+
- Remove leftover code in Combobox component ([#1514](https://github.com/tailwindlabs/headlessui/pull/1514))
1819

1920
## [Unreleased - @headlessui/vue]
2021

@@ -26,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2627
### Fixed
2728

2829
- Ensure `Escape` propagates correctly in `Combobox` component ([#1511](https://github.com/tailwindlabs/headlessui/pull/1511))
30+
- Remove leftover code in Combobox component ([#1514](https://github.com/tailwindlabs/headlessui/pull/1514))
2931

3032
## [Unreleased - @headlessui/tailwindcss]
3133

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

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -663,18 +663,6 @@ let Input = forwardRefWithAs(function Input<
663663
},
664664
[ComboboxState.Closed]: () => {
665665
actions.openCombobox()
666-
// TODO: We can't do this outside next frame because the options aren't rendered yet
667-
// But doing this in next frame results in a flicker because the dom mutations are async here
668-
// Basically:
669-
// Sync -> no option list yet
670-
// Next frame -> option list already rendered with selection -> dispatch -> next frame -> now we have the focus on the right element
671-
672-
// TODO: The spec here is underspecified. There's mention of skipping to the next item when autocomplete has suggested something but nothing regarding a non-autocomplete selection/value
673-
d.nextFrame(() => {
674-
if (!data.value) {
675-
actions.goToOption(Focus.Next)
676-
}
677-
})
678666
},
679667
})
680668

@@ -804,18 +792,6 @@ let Button = forwardRefWithAs(function Button<TTag extends ElementType = typeof
804792
event.stopPropagation()
805793
if (data.comboboxState === ComboboxState.Closed) {
806794
actions.openCombobox()
807-
// TODO: We can't do this outside next frame because the options aren't rendered yet
808-
// But doing this in next frame results in a flicker because the dom mutations are async here
809-
// Basically:
810-
// Sync -> no option list yet
811-
// Next frame -> option list already rendered with selection -> dispatch -> next frame -> now we have the focus on the right element
812-
813-
// TODO: The spec here is underspecified. There's mention of skipping to the next item when autocomplete has suggested something but nothing regarding a non-autocomplete selection/value
814-
d.nextFrame(() => {
815-
if (!data.value) {
816-
actions.goToOption(Focus.First)
817-
}
818-
})
819795
}
820796
return d.nextFrame(() => data.inputRef.current?.focus({ preventScroll: true }))
821797

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

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -545,18 +545,6 @@ export let ComboboxButton = defineComponent({
545545
event.stopPropagation()
546546
if (api.comboboxState.value === ComboboxStates.Closed) {
547547
api.openCombobox()
548-
// TODO: We can't do this outside next frame because the options aren't rendered yet
549-
// But doing this in next frame results in a flicker because the dom mutations are async here
550-
// Basically:
551-
// Sync -> no option list yet
552-
// Next frame -> option list already rendered with selection -> dispatch -> next frame -> now we have the focus on the right element
553-
554-
// TODO: The spec here is underspecified. There's mention of skipping to the next item when autocomplete has suggested something but nothing regarding a non-autocomplete selection/value
555-
nextTick(() => {
556-
if (!api.value.value) {
557-
api.goToOption(Focus.First)
558-
}
559-
})
560548
}
561549
nextTick(() => api.inputRef.value?.focus({ preventScroll: true }))
562550
return
@@ -689,14 +677,7 @@ export let ComboboxInput = defineComponent({
689677
event.stopPropagation()
690678
return match(api.comboboxState.value, {
691679
[ComboboxStates.Open]: () => api.goToOption(Focus.Next),
692-
[ComboboxStates.Closed]: () => {
693-
api.openCombobox()
694-
nextTick(() => {
695-
if (!api.value.value) {
696-
api.goToOption(Focus.First)
697-
}
698-
})
699-
},
680+
[ComboboxStates.Closed]: () => api.openCombobox(),
700681
})
701682

702683
case Keys.ArrowUp:

0 commit comments

Comments
 (0)