Skip to content

Commit

Permalink
fix(FormText): 'muted' prop bug in <FormText />. (#3901)
Browse files Browse the repository at this point in the history
  • Loading branch information
rockchalkwushock authored and jquense committed Jun 14, 2019
1 parent d0e259c commit 0bb8a6f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/FormText.js
Original file line number Diff line number Diff line change
Expand Up @@ -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} />;
},
);

Expand Down
13 changes: 13 additions & 0 deletions test/FormTextSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.