Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(Button): remove extra close icon in btn-close (#2318)
The close icon is now included automatically in Bootstrap 5. See https://getbootstrap.com/docs/5.1/components/close-button/#example
  • Loading branch information
phwebi committed Oct 27, 2021
1 parent 3bfce12 commit e4affb4
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 20 deletions.
4 changes: 0 additions & 4 deletions src/Button.js
Expand Up @@ -59,10 +59,6 @@ class Button extends React.Component {
...attributes
} = this.props;

if (close && typeof attributes.children === 'undefined') {
attributes.children = <span aria-hidden>×</span>;
}

const btnOutlineColor = `btn${outline ? '-outline' : ''}-${color}`;

const classes = mapToCssModules(classNames(
Expand Down
14 changes: 0 additions & 14 deletions src/__tests__/Button.spec.js
Expand Up @@ -97,20 +97,6 @@ describe('Button', () => {
expect(block.hasClass('d-block w-100')).toBe(true);
});

it('should render close icon utility with default props', () => {
const times = '×'; // unicode: U+00D7 MULTIPLICATION SIGN
const expectedInnerHTML = `<span aria-hidden="true">${times}</span>`;

const wrapper = shallow(<Button close />);
const actualInnerHTML = wrapper.children().html();

expect(wrapper.find('.btn-close').length).toBe(1);
expect(wrapper.find('.btn').length).toBe(0);
expect(wrapper.find('.btn-secondary').length).toBe(0);
expect(wrapper.find('button').prop('aria-label')).toMatch(/close/i);
expect(actualInnerHTML).toBe(expectedInnerHTML);
});

it('should render close icon with custom child and props', () => {
const testChild = 'close this thing';
const wrapper = shallow(<Button close>{testChild}</Button>);
Expand Down
4 changes: 2 additions & 2 deletions stories/examples/ButtonCloseIcon.js
@@ -1,5 +1,5 @@
import React, { Component } from 'react';
import { Button, Card, CardBody, CardText, CardGroup, CardTitle } from 'reactstrap';
import React from 'react';
import { Button } from 'reactstrap';

const Example = (props) => (
<div>
Expand Down

0 comments on commit e4affb4

Please sign in to comment.