Skip to content

Commit

Permalink
fix(Dropdown): error message when passing a function to innerRef (#2932)
Browse files Browse the repository at this point in the history
  • Loading branch information
joakbjerk authored Nov 28, 2023
1 parent e4fd9f9 commit c362a4a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/components/button/Button.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export type ButtonProps = {
*/
skeleton?: ButtonSkeleton;
disabled?: boolean;
inner_ref?: any;
inner_ref?: React.Ref;
className?: string;
innerRef?: any;
/**
Expand Down
12 changes: 8 additions & 4 deletions packages/dnb-eufemia/src/components/button/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,14 @@ export default class Button extends React.PureComponent {

componentDidMount() {
if (this.props.innerRef) {
this.props.innerRef.current = this._ref.current
typeof this.props.innerRef === 'function'
? this.props.innerRef(this._ref.current)
: (this.props.innerRef.current = this._ref.current)
}
if (this.props.inner_ref) {
this.props.inner_ref.current = this._ref.current
typeof this.props.innerRef === 'function'
? this.props.inner_ref(this._ref.current)
: (this.props.inner_ref.current = this._ref.current)
}
}

Expand Down Expand Up @@ -313,10 +317,10 @@ Button.propTypes = {
stretch: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
skeleton: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
disabled: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
inner_ref: PropTypes.object,
inner_ref: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),

className: PropTypes.string,
innerRef: PropTypes.object,
innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
children: PropTypes.oneOfType([
PropTypes.string,
PropTypes.func,
Expand Down
4 changes: 2 additions & 2 deletions packages/dnb-eufemia/src/components/dropdown/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ export default class Dropdown extends React.PureComponent {
PropTypes.string,
PropTypes.bool,
]),
innerRef: PropTypes.object,
buttonRef: PropTypes.object,
innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
buttonRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
globalStatus: PropTypes.shape({
id: PropTypes.string,
message: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
Expand Down

0 comments on commit c362a4a

Please sign in to comment.