Skip to content

Commit

Permalink
fix(components): remove invalid Button props from HTML (#548)
Browse files Browse the repository at this point in the history
* fix: don't pass invalid props to Link

* fix: added unit test

* fix: implemented shouldForwardProp
  • Loading branch information
dmitri-suvorov-sumup authored Mar 4, 2020
1 parent f977b8d commit 5795ea1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/components/Button/components/PlainButton/PlainButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import React from 'react';
import styled from '@emotion/styled';
import { css } from '@emotion/core';
import isPropValid from '@emotion/is-prop-valid';

import { StyledText } from '../../../Text';

Expand Down Expand Up @@ -49,10 +50,9 @@ const primaryStyles = ({ theme, primary }) =>
}
`;

const ButtonLinkWrapper = styled(StyledText)(
baseStyles,
primaryStyles
).withComponent('button');
const ButtonLinkWrapper = styled(StyledText, {
shouldForwardProp: isPropValid
})(baseStyles, primaryStyles).withComponent('button');

/* eslint-disable react/prop-types */
const PlainButton = ({ components, href, ...rest }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import React from 'react';
import styled from '@emotion/styled';
import { css } from '@emotion/core';
import isPropValid from '@emotion/is-prop-valid';

import { textMega, calculatePadding } from '../../../../styles/style-helpers';

Expand Down Expand Up @@ -215,7 +216,9 @@ const buttonLoadingStyles = ({ isLoading }) =>
pointer-events: none;
`;

const ButtonElement = styled('button')`
const ButtonElement = styled('button', {
shouldForwardProp: isPropValid
})`
${baseStyles};
${primaryStyles};
${sizeStyles};
Expand Down
11 changes: 4 additions & 7 deletions src/components/Sidebar/components/NavItem/NavItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import styled from '@emotion/styled';
import { css } from '@emotion/core';
import isPropValid from '@emotion/is-prop-valid';

import { componentsPropType } from '../../../../util/shared-prop-types';
import NavLabel from '../NavLabel';
Expand Down Expand Up @@ -82,13 +83,9 @@ const disabledStyles = ({ theme, disabled }) =>
}
`;

const StyledLink = styled.a(
baseStyles,
hoverStyles,
selectedStyles,
secondaryStyles,
disabledStyles
);
const StyledLink = styled('a', {
shouldForwardProp: isPropValid
})(baseStyles, hoverStyles, selectedStyles, secondaryStyles, disabledStyles);

const NavItem = ({
label,
Expand Down

1 comment on commit 5795ea1

@vercel
Copy link

@vercel vercel bot commented on 5795ea1 Mar 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.