Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Unsupported props passed to TooltipToggleButton #818

Open
ketsappi opened this issue Dec 22, 2023 · 0 comments
Open

[Bug] Unsupported props passed to TooltipToggleButton #818

ketsappi opened this issue Dec 22, 2023 · 0 comments

Comments

@ketsappi
Copy link
Contributor

Problem

When running tests, test has errors which still passes the test for some reason:

PASS  src/core/Tooltip/Tooltip.test.tsx

    console.error
      Warning: Unknown event handler property `onToggleButtonClick`. It will be ignored.
          at button
          at Button (/suomifi-ui-components/src/reset/HtmlButton/HtmlButton.tsx:35:31)
          at shouldForwardProp (/suomifi-ui-components/node_modules/styled-components/src/models/StyledComponent.js:253:26)
          at BaseTooltipToggleButton (/suomifi-ui-components/src/core/Tooltip/TooltipToggleButton/TooltipToggleButton.tsx:21:42)
          at /suomifi-ui-components/src/core/Tooltip/TooltipToggleButton/TooltipToggleButton.tsx:50:10
          at shouldForwardProp (/suomifi-ui-components/node_modules/styled-components/src/models/StyledComponent.js:253:26)
          at BaseTooltip (/suomifi-ui-components/src/core/Tooltip/Tooltip.tsx:63:5)
          at Tooltip

       96 |     it('is clicked; given method called', () => {
       97 |       const mockClickHandler = jest.fn();
    >  98 |       render(
          |             ^


 console.error
      Warning: Unknown event handler property `onCloseButtonClick`. It will be ignored.
          at button
          at Button (/suomifi-ui-components/src/reset/HtmlButton/HtmlButton.tsx:35:31)
          at shouldForwardProp (/suomifi-ui-components/node_modules/styled-components/src/models/StyledComponent.js:253:26)
          at BaseTooltipToggleButton (/suomifi-ui-components/src/core/Tooltip/TooltipToggleButton/TooltipToggleButton.tsx:21:42)
          at /suomifi-ui-components/src/core/Tooltip/TooltipToggleButton/TooltipToggleButton.tsx:50:10
          at shouldForwardProp (/suomifi-ui-components/node_modules/styled-components/src/models/StyledComponent.js:253:26)
          at BaseTooltip (/suomifi-ui-components/src/core/Tooltip/Tooltip.tsx:63:5)
          at Tooltip

      114 |     it('is clicked; given method called', () => {
      115 |       const mockClickHandler = jest.fn();
    > 116 |       render(
          |             ^

Location

Problem location:

const {
open: propsOpen,
children,
ariaToggleButtonLabelText,
ariaCloseButtonLabelText,
toggleButtonClassName,
contentClassName,
forwardedRef,
className,
...passProps
} = this.props;
const open = 'open' in this.props ? propsOpen : this.state.open;
// Remove the possibility to have undefined forwardedRef as a parameter for forkRefs
const definedRef = forwardedRef || null;
return (
<>
<TooltipToggleButton
className={classnames(
className,
baseClassName,
toggleButtonClassName,
)}
ref={forkRefs(this.toggleButtonRef, definedRef)}
aria-label={ariaToggleButtonLabelText}
aria-expanded={open}
onClick={this.handleToggleClick}
{...passProps}

Possible solution

Should be only passing supported props.

Maybe destructuring the onToggleButtonClick and onCloseButtonClick so that they will not with the passProps to TooltipToggleButton.

Steps to Reproduce the Problem

Run npm run test and find the error from the list.

Specifications

  • Version: 13.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant