Skip to content

Commit

Permalink
merge incoming style prop
Browse files Browse the repository at this point in the history
We were overriding the `style` prop entirely on the `<ComboboxOptions>`,
`<ListboxOptions>`, `<MenuItems>`, and `<PopoverPanel>` for anchoring
purposes, as well as provided some CSS variables.

This now ensures that the incoming `style` prop gets merged in.
  • Loading branch information
RobinMalfait committed May 28, 2024
1 parent 7267cc4 commit 803d56f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1695,6 +1695,7 @@ function OptionsFn<TTag extends ElementType = typeof DEFAULT_OPTIONS_TAG>(
id,
ref: optionsRef,
style: {
...theirProps.style,
...style,
'--input-width': useElementSize(data.inputRef, true).width,
'--button-width': useElementSize(data.buttonRef, true).width,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ function OptionsFn<TTag extends ElementType = typeof DEFAULT_OPTIONS_TAG>(
role: 'listbox',
tabIndex: 0,
style: {
...theirProps.style,
...style,
'--button-width': useElementSize(data.buttonRef, true).width,
} as CSSProperties,
Expand Down
1 change: 1 addition & 0 deletions packages/@headlessui-react/src/components/menu/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,7 @@ function ItemsFn<TTag extends ElementType = typeof DEFAULT_ITEMS_TAG>(
tabIndex: 0,
ref: itemsRef,
style: {
...theirProps.style,
...style,
'--button-width': useElementSize(state.buttonRef, true).width,
} as CSSProperties,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,7 @@ function PanelFn<TTag extends ElementType = typeof DEFAULT_PANEL_TAG>(
: undefined,
tabIndex: -1,
style: {
...theirProps.style,
...style,
'--button-width': useElementSize(state.button, true).width,
} as React.CSSProperties,
Expand Down

0 comments on commit 803d56f

Please sign in to comment.