Skip to content

Commit

Permalink
Merge pull request #504 from mmarkelov/Fix_adding_undefined_to_class
Browse files Browse the repository at this point in the history
Fix adding undefined to class
  • Loading branch information
patrickm68 committed Apr 28, 2020
2 parents 652797b + 8b5326b commit 098ab55
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/CSSTransition.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,10 @@ class CSSTransition extends React.Component {

addClass(node, type, phase) {
let className = this.getClassNames(type)[`${phase}ClassName`];
const { doneClassName } = this.getClassNames('enter');

if (type === 'appear' && phase === 'done') {
className += ` ${this.getClassNames('enter').doneClassName}`;
if (type === 'appear' && phase === 'done' && doneClassName) {
className += ` ${doneClassName}`;
}

// This is for to force a repaint,
Expand All @@ -185,8 +186,10 @@ class CSSTransition extends React.Component {
node && node.scrollTop;
}

this.appliedClasses[type][phase] = className
addClass(node, className)
if (className) {
this.appliedClasses[type][phase] = className
addClass(node, className)
}
}

removeClasses(node, type) {
Expand Down
24 changes: 23 additions & 1 deletion test/CSSTransition-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,29 @@ describe('CSSTransition', () => {
<div />
</CSSTransition>
)
})
});

it('should not add undefined when appearDone is not defined', done => {
mount(
<CSSTransition
timeout={10}
classNames={{ appear: 'appear-test' }}
in={true}
appear={true}
onEnter={(node, isAppearing) => {
expect(isAppearing).toEqual(true);
expect(node.className).toEqual('appear-test');
}}
onEntered={(node, isAppearing) => {
expect(isAppearing).toEqual(true);
expect(node.className).toEqual('');
done();
}}
>
<div/>
</CSSTransition>
);
});

it('should not be appearing in normal enter mode', done => {
let count = 0;
Expand Down

0 comments on commit 098ab55

Please sign in to comment.