Skip to content

Commit

Permalink
Merge pull request primefaces#6264 from melloware/PR6263
Browse files Browse the repository at this point in the history
Fix primefaces#6263: ButtonGroup use forwardRef properly
  • Loading branch information
gucal authored Apr 1, 2024
2 parents 4e623ed + 36fb354 commit 2d08fb7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions components/lib/buttongroup/ButtonGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,28 @@ import * as React from 'react';
import { PrimeReactContext } from '../api/Api';
import { useHandleStyle } from '../componentbase/ComponentBase';
import { useMergeProps } from '../hooks/Hooks';
import { classNames } from '../utils/Utils';
import { ObjectUtils, classNames } from '../utils/Utils';
import { ButtonGroupBase } from './ButtonGroupBase';

export const ButtonGroup = React.memo(
React.forwardRef((inProps) => {
React.forwardRef((inProps, ref) => {
const mergeProps = useMergeProps();
const context = React.useContext(PrimeReactContext);
const props = ButtonGroupBase.getProps(inProps, context);
const elementRef = React.useRef(ref);
const { ptm, cx, isUnstyled } = ButtonGroupBase.setMetaData({
props
});

useHandleStyle(ButtonGroupBase.css.styles, isUnstyled, { name: 'buttongroup' });

React.useEffect(() => {
ObjectUtils.combinedRefs(elementRef, ref);
}, [elementRef, ref]);

const rootProps = mergeProps(
{
ref: elementRef,
className: classNames(cx('root')),
role: 'group'
},
Expand Down

0 comments on commit 2d08fb7

Please sign in to comment.