[Snyk] Upgrade @headlessui/react from 1.7.19 to 2.0.3 #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR was automatically created by Snyk using the credentials of a real user.

Snyk has created this PR to upgrade @headlessui/react from 1.7.19 to 2.0.3.
ℹ️ Keep your dependencies up-to-date. This makes it easier to fix existing vulnerabilities and to more quickly identify and fix newly disclosed vulnerabilities when they affect your project.
The recommended version is 8 versions ahead of your current version.
The recommended version was released on 22 days ago.
Release notes
Package name: @headlessui/react
Fixed
<Combobox>works (#3182)Fixed
useInertOthershook (#3181)Fixed
<DialogPanel>and<DialogTitle>(#3176)We just released Headless UI v2.0 for React which includes a ton of new stuff:
Menu,Listbox, and more can now automatically position their popovers to be anchored to their trigger, adapting as needed to changes in the viewport.Checkboxcomponent to complement our existingRadioGroupcomponent, making it easy to build totally custom checkbox controls.Input,Select,Textarea,Label,Description,Fieldset, andLegendcomponents that handle all of the ID generation andaria-*attribute mapping you need to do to connect form fields together.data-hoveranddata-focusattributes to your controls that behave more consistently across different devices than the native pseudo-classes.Comboboxcomponent can now handle giant lists of options with no performance issues.Changelog
Added
Checkboxcomponent (#2887, #2962)Buttoncomponent (#2887)Inputcomponent (#2887, #2902, #2940)Textareacomponent (#2887, #2902, #2940)Selectcomponent (#2887, #2902)FieldsetandLegendcomponents (#2887)Field,Label,Descriptioncomponents (#2887, #2941)MenuSection,MenuHeading, andMenuSeparatorcomponents (#2887)ListboxSelectedOptioncomponent (#2887)DataInteractivecomponent (#2887)CloseButtoncomponent anduseClosehook (#3096)anchor,modal, andportalprops toCombobox,Listbox,MenuandPopovercomponents (#2887, #3075, #3097, #3111, #3115, #3121, #3124, #3133, #3138, #3148, #3152, #3154, #3157)autoFocusprop to focusable components (#2887)virtualprop toComboboxcomponent (#2779, #3128, #3160, #3161, #3163)onCloseprop toComboboxcomponent (#3122)immediateprop toComboboxfor immediately opening the Combobox when theinputreceives focus (#2686)--button-widthCSS variable on theListboxOptions,MenuItems, andPopoverPanelcomponents (#2887, #3058)--input-widthand--button-widthCSS variables on theComboboxOptionscomponent (#3057)data-*attributes as an alternative to the existingdata-headlessui-stateattribute (#2887, #3035, #3061)Fixed
disabledoraria-disabledattributes (#2890)displayValuecallback inComboboxInputcomponent (#3048)multipleprop inComboboxcomponent (#3099)ComboboxInputcomponent (#3065, #3073)Transitioncomponent (#3074)ListboxOptionsandMenuItemscomponents (#3112)Dialogcomponent (#2889)Changed
Checkbox,SwitchandRadioGroupcomponents (#3095)RadioGroup.Optioncomponent in favor of newRadiocomponent (#2887)activeprop in favor of newfocusprop (#2887)ListboxOptions,ListboxOption,ComboboxOptions,ComboboxOption, andTabGroupcomponents (#3109)divtoFragmentonTransitioncomponents (#3110, #3147)Comboboxcomponent to havenullvalue (#3064, #3100)ListboxButtoncomponent (#2972)enteredprop on theTransitioncomponent (#3089)ComboboxOptionscomponent (#3126)Upgrading from v1
Update dependencies
Install the latest version of the package via npm:
Comboboxes now always support empty values
Previously the
Comboboxcomponent required an option to always be set, and you could opt out of this behavior using thenullableprop. In v2.0 comboboxes support empty values by default so you can remove this prop:If you'd like to keep the previous behavior, update your
onChangecallback to only set the selected value if an option has actually been selected:<Combobox value={selected} - onChange={setSelected} + onChange={(newValue) => setSelected((oldValue) => newValue ?? oldValue)} onClose={() => setQuery('')} >New default elements
The default rendered element has changed for a number of components in v2.0:
TransitiondivFragmentTransitionRootdivFragmentTransitionChilddivFragmentListboxOptionsuldivListboxOptionlidivComboboxOptionsuldivComboboxOptionlidivTabGroupFragmentdivIf you're relying on a default element that has change, you can preserve that behavior using the
asprop:Dialogs no longer require a focusable child
Previously the
Dialogcomponent would automatically focus the first focusable child on open. This meant that you had to have at least one focusable element within your dialog, otherwise you would see a warning in your console.In v2.0 that is no longer the case and the dialog's root element is focused instead on open.
If you'd like a child element to receive focus when your dialog is opened, you can add the
autoFocusprop to any Headless UI form control:For non-Headless UI components, you can add the
data-autofocusattribute to any focusable element:Dropdown components are now modal by default
The
Menu,Combobox, andListboxdropdowns are now rendered modal by default. When the dropdown is open the page is scroll-locked and all other page content is madeinert.While this is generally recommended behavior for these components, you can disable this using the
modalprop:Dialog.OverlayandDialog.Backdropcomponents removedIn Headless UI v1.6 we deprecated the
Dialog.OverlayandDialog.Backdropcomponents. These have now been removed in v2.0.If you're using either of these components, you can update your app to use the new
DialogPanelapproach:Deprecated component dot-notation
The previous component dot-notation has been deprecated in favor of using explicit imports for each individual component. This is to improve compatibility with RSC (React Server Components) and tree-shaking.
We recommend updating to this new API:
+ import { Menu, MenuButton, MenuItems, MenuItem } from '@ headlessui/react'
function Example() {
return (
<Menu>
- <Menu.Button>My account</Menu.Button>
- <Menu.Items>
- <Menu.Item><a href="/settings">Settings</a></Menu.Item>
- <Menu.Item><a href="/support">Support</a></Menu.Item>
- <Menu.Item><a href="/license">License</a></Menu.Item>
- </Menu.Items>
+ <MenuButton>My account</MenuButton>
+ <MenuItems>
+ <MenuItem><a href="/settings">Settings</a></MenuItem>
+ <MenuItem><a href="/support">Support</a></MenuItem>
+ <MenuItem><a href="/license">License</a></MenuItem>
+ </MenuItems>
</Menu>
)
}
Deprecated component-specific label and description components
With the addition of the multi-purpose
Field,LabelandDescriptioncomponents in v2, we've deprecated the component-specific versions.Combobox.LabelLabelDialog.DescriptionDescriptionListbox.LabelLabelRadioGroup.DescriptionDescriptionRadioGroup.LabelLabelSwitch.DescriptionDescriptionSwitch.GroupFieldSwitch.LabelLabelWe recommend updating to these new components:
+ import { Combobox, ComboboxInput, ComboboxOptions, Field, Label } from '@ headlessui/react'
function Example() {
return (
- <Combobox>
- <Combobox.Label>Assignee:</Combobox.Label>
- <Combobox.Input />
- <Combobox.Options>{/* ... /}</Combobox.Options>
- </Combobox>
+ <Field>
+ <Label>Assignee:</Label>
+ <Combobox>
+ <ComboboxInput />
+ <ComboboxOptions>{/ ... */}</ComboboxOptions>
+ </Combobox>
+ <Field>
)
}
Deprecated
RadioGroup.OptioncomponentWe've deprecated the
RadioGroup.Optionin favor of the more terseRadiocomponent.We recommend updating to this new component:
Deprecated
activeprop in favor offocusWe've deprecated the
activeprop in favor of the newfocusprop on theComboboxOption,ListboxOption,ListboxOption,MenuItem,MenuItem,RadioOption, andRadioOptioncomponents.We recommend updating to this new prop:
Deprecated
@ headlessui/tailwindcsspackageWith the availability of the new
data-*attributes in v2.0, we've deprecated the@ headlessui/tailwindcsspackage.We recommend updating to use the new
data-*attributes instead. Start by removing this package:Next, replace the
ui-*class modifiers withdata-[*]modifiers:<MenuItem as="a" href="#" - className="ui-active:bg-blue-500 ui-active:text-white" + className="data-[active]:bg-blue-500 data-[active]:text-white" > {*/ ...*/} </MenuItem>Fixed
disabledstate on<Tab />component (#2918)Dialog.Panel(#2919)hiddenattribute to internal<Hidden />component when theFeatures.Hiddenfeature is used (#2955)tabIndexon the<Switch />component (#2966)disabledstate to hidden inputs in form-like components (#3004)selectedIndexfor controlled<Tab/>components (#3037)Important
Note: You are seeing this because you or someone else with access to this repository has authorized Snyk to open upgrade PRs.
For more information: