Skip to content
Permalink
Browse files

fix(FormText): 'muted' prop bug in <FormText />. (#3901)

  • Loading branch information
rockchalkwushock authored and jquense committed Jun 14, 2019
1 parent d0e259c commit 0bb8a6fd4ad110c49e5e89f05228ade0968652bf
Showing with 18 additions and 8 deletions.
  1. +5 −8 src/FormText.js
  2. +13 −0 test/FormTextSpec.js
@@ -29,15 +29,12 @@ const propTypes = {

const FormText = React.forwardRef(
// Need to define the default "as" during prop destructuring to be compatible with styled-components github.com/react-bootstrap/react-bootstrap/issues/3595
({ bsPrefix, className, as: Component = 'small', ...props }, ref) => {
({ bsPrefix, className, as: Component = 'small', muted, ...props }, ref) => {
bsPrefix = useBootstrapPrefix(bsPrefix, 'form-text');
return (
<Component
{...props}
ref={ref}
className={classNames(className, bsPrefix)}
/>
);

const classes = classNames(className, bsPrefix, muted && 'text-muted');

return <Component {...props} ref={ref} className={classes} />;
},
);

@@ -19,4 +19,17 @@ describe('<FormText>', () => {
it('Should have small as default component', () => {
mount(<FormText />).assertSingle('small');
});

it('Should have "form-text" & "text-muted" class', () => {
expect(
mount(<FormText muted />)
.find('small')
.hasClass('form-text'),
).to.equal(true);
expect(
mount(<FormText muted />)
.find('small')
.hasClass('text-muted'),
).to.equal(true);
});
});

0 comments on commit 0bb8a6f

Please sign in to comment.
You can’t perform that action at this time.