Skip to content

Commit 0bb8a6f

Browse files
rockchalkwushockjquense
authored andcommitted
fix(FormText): 'muted' prop bug in <FormText />. (react-bootstrap#3901)
1 parent d0e259c commit 0bb8a6f

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

src/FormText.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,12 @@ const propTypes = {
2929

3030
const FormText = React.forwardRef(
3131
// Need to define the default "as" during prop destructuring to be compatible with styled-components github.com/react-bootstrap/react-bootstrap/issues/3595
32-
({ bsPrefix, className, as: Component = 'small', ...props }, ref) => {
32+
({ bsPrefix, className, as: Component = 'small', muted, ...props }, ref) => {
3333
bsPrefix = useBootstrapPrefix(bsPrefix, 'form-text');
34-
return (
35-
<Component
36-
{...props}
37-
ref={ref}
38-
className={classNames(className, bsPrefix)}
39-
/>
40-
);
34+
35+
const classes = classNames(className, bsPrefix, muted && 'text-muted');
36+
37+
return <Component {...props} ref={ref} className={classes} />;
4138
},
4239
);
4340

test/FormTextSpec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,17 @@ describe('<FormText>', () => {
1919
it('Should have small as default component', () => {
2020
mount(<FormText />).assertSingle('small');
2121
});
22+
23+
it('Should have "form-text" & "text-muted" class', () => {
24+
expect(
25+
mount(<FormText muted />)
26+
.find('small')
27+
.hasClass('form-text'),
28+
).to.equal(true);
29+
expect(
30+
mount(<FormText muted />)
31+
.find('small')
32+
.hasClass('text-muted'),
33+
).to.equal(true);
34+
});
2235
});

0 commit comments

Comments
 (0)