Skip to content

Commit

Permalink
Fix #6359: Stepper proper forwardRef (#6362)
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware authored Apr 9, 2024
1 parent 88e9c2a commit f4afde4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
3 changes: 2 additions & 1 deletion components/lib/stepper/StepperContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import * as React from 'react';
import { useMergeProps } from '../hooks/Hooks';

export const StepperContent = React.memo(
React.forwardRef((props) => {
React.forwardRef((props, ref) => {
const mergeProps = useMergeProps();
const { cx, ptm } = props;

const rootProps = mergeProps(
{
ref: ref,
id: props.id,
className: cx('stepper.content', { stepperpanel: props.stepperpanel, index: props.index }),
role: 'tabpanel',
Expand Down
3 changes: 2 additions & 1 deletion components/lib/stepper/StepperHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import * as React from 'react';
import { useMergeProps } from '../hooks/Hooks';

export const StepperHeader = React.memo(
React.forwardRef((props) => {
React.forwardRef((props, ref) => {
const mergeProps = useMergeProps();
const { cx } = props;

const buttonProps = mergeProps({
ref: ref,
id: props.id,
className: cx('stepper.action'),
role: 'tab',
Expand Down
3 changes: 2 additions & 1 deletion components/lib/stepper/StepperSeparator.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import * as React from 'react';
import { useMergeProps } from '../hooks/Hooks';

export const StepperSeparator = React.memo(
React.forwardRef((props) => {
React.forwardRef((props, ref) => {
const mergeProps = useMergeProps();

const separatorProps = mergeProps({
ref: ref,
'aria-hidden': true,
className: props.separatorClass,
...props.getStepPT(props.stepperpanel, 'separator', props.index)
Expand Down
6 changes: 0 additions & 6 deletions components/lib/stepperpanel/StepperPanel.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
import * as React from 'react';
import { PrimeReactContext } from '../api/Api';
import { useHandleStyle } from '../componentbase/ComponentBase';
import { ObjectUtils } from '../utils/Utils';
import { StepperPanelBase } from './StepperPanelBase';

export const StepperPanel = React.memo(
React.forwardRef((inProps, ref) => {
const context = React.useContext(PrimeReactContext);
const props = StepperPanelBase.getProps(inProps, context);
const elementRef = React.useRef(ref);
const { isUnstyled } = StepperPanelBase.setMetaData({
props
});

useHandleStyle(StepperPanelBase.css.styles, isUnstyled, { name: 'StepperPanel' });

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

return <span ref={ref}>{props.children}</span>;
})
);
Expand Down

0 comments on commit f4afde4

Please sign in to comment.