Skip to content

Commit

Permalink
Fix focus border cut-off
Browse files Browse the repository at this point in the history
  • Loading branch information
Alf Bjørn Hustoft committed Apr 21, 2017
1 parent 80d8b85 commit ecb9bd2
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGELOG

## 1.0.7
Make room for button focus border when button is at the bottom of the expanded area

## 1.0.6
Make sure content has 100% width of container

Expand Down
3 changes: 3 additions & 0 deletions examples/ExpandableDemo.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class ExpandableDemo extends Component {
<ComponentIpsum />
<ComponentIpsum />
<ComponentIpsum />
<button className="button-in-expandable">
A button
</button>
</Expandable>
<h3 className="ffe-h3">Here is more content after the expandable content</h3>
<ComponentIpsum />
Expand Down
5 changes: 5 additions & 0 deletions examples/examples.less
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ body {
.example-class {
margin: 10px 0;
}

.button-in-expandable {
border: none;
color: #0071CD;
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ffe-expandable-react",
"version": "1.0.6",
"version": "1.0.7",
"main": "lib/ffe-expandable-react.js",
"scripts": {
"build": "babel -d lib/. --ignore=*.test.js src/.",
Expand Down
4 changes: 2 additions & 2 deletions src/ffe-expandable-react.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ class Expandable extends React.Component {
const ExpandedElementTag = isTable ? 'td' : 'div';

const styles = {
maxHeight: isOpen ? height : 0,
height: isOpen ? height + 2 : 0,
overflow: 'hidden',
transition: `max-height ${expandTime}s ease-out`,
transition: `height ${expandTime}s ease-out`,
};

return (
Expand Down
8 changes: 4 additions & 4 deletions src/ffe-expandable-react.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ describe('ffe-expandable-react', () => {
expect(componentMounted).to.contain(<ExpandedContent />);
});

it('has wrapped Expandable with max-height set to 5000', () => {
expect(componentMounted.find('.expandable-wrapper')).to.have.style('max-height', '5000px');
it('adds 2 pixels to height to allow for focus border', () => {
expect(componentMounted.find('.expandable-wrapper')).to.have.style('height', '5002px');
});

it('has wrapped Expandable with max-height set to 0 when isOpen is false', () => {
it('has wrapped Expandable with height set to 0px when isOpen is false', () => {
componentMounted = mount(
<Expandable
isOpen={false}
Expand All @@ -50,6 +50,6 @@ describe('ffe-expandable-react', () => {
customClass="expandable-wrapper"
/>
);
expect(componentMounted.find('.expandable-wrapper')).to.have.style('max-height', '0');
expect(componentMounted.find('.expandable-wrapper')).to.have.style('height', '0px');
});
});

0 comments on commit ecb9bd2

Please sign in to comment.