Skip to content

Commit

Permalink
fix(react): allow passing options to floating ui middlewares
Browse files Browse the repository at this point in the history
  • Loading branch information
dackmin committed Sep 28, 2022
1 parent 4dbf63c commit 0c273fe
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/react/lib/Dropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ const Dropdown = forwardRef(({
container,
disabled,
floatingOptions,
clickOptions,
hoverOptions,
dismissOptions,
opened = false,
placement = 'bottom-start',
trigger = 'click',
Expand Down Expand Up @@ -57,13 +60,16 @@ const Dropdown = forwardRef(({
const { getReferenceProps, getFloatingProps } = useInteractions([
useClick(context, {
enabled: trigger === 'click',
...clickOptions || {},
}),
useHover(context, {
enabled: trigger === 'hover',
handleClose: safePolygon(),
...hoverOptions || {},
}),
useDismiss(context, {
enabled: trigger === 'click',
...dismissOptions || {},
}),
]);

Expand Down Expand Up @@ -154,17 +160,20 @@ const Dropdown = forwardRef(({

Dropdown.displayName = 'Dropdown';
Dropdown.propTypes = {
clickOptions: PropTypes.object,
container: PropTypes.oneOfType([
PropTypes.string,
PropTypes.func,
PropTypes.object,
PropTypes.node,
]),
disabled: PropTypes.bool,
dismissOptions: PropTypes.object,
floatingOptions: PropTypes.object,
hoverOptions: PropTypes.object,
opened: PropTypes.bool,
placement: PropTypes.string,
trigger: PropTypes.oneOf(['click', 'hover', 'manual']),
floatingOptions: PropTypes.object,
onToggle: PropTypes.func,
};

Expand Down

0 comments on commit 0c273fe

Please sign in to comment.