Skip to content

Commit aa09e81

Browse files
committed
Only switch the container to relative positioning just before and during transitions.
1 parent 75e6243 commit aa09e81

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
### v3.0.1 (2 October 2017)
22

33
* [BUGFIX] Prevent animating child selection with CSS rather than clearing with JS so form inputs don't lose focus on each update. (#50)
4+
* [BUGFIX] Switch the container to relative positioning on the render before the transitions start to avoid the glitch
5+
in Edge without using permanent relative positioning which is not an option. (#52)
46

57
### v3.0.0 (27 August 2017)
68

src/ReactCSSTransitionReplace.jsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,17 @@ export default class ReactCSSTransitionReplace extends React.Component {
251251
...containerProps
252252
} = this.props
253253

254-
// In edge there is a glitch as the container switches from not positioned
255-
// to a positioned element at the start of a transition which is solved
256-
// by applying the position and overflow style rules at all times.
254+
const transitioning = this.shouldEnterCurrent || this.keysToLeave.length || Object.keys(this.transitioningKeys).length
255+
257256
containerProps.style = {
258257
...containerProps.style,
259-
position: 'relative',
260258
}
261-
if (overflowHidden) {
262-
containerProps.style.overflow = 'hidden'
259+
260+
if (transitioning) {
261+
containerProps.style.position = 'relative'
262+
if (overflowHidden) {
263+
containerProps.style.overflow = 'hidden'
264+
}
263265
}
264266

265267
if (height !== null) {
@@ -306,9 +308,11 @@ export default class ReactCSSTransitionReplace extends React.Component {
306308
React.createElement(childComponent,
307309
{
308310
key: currentKey,
309-
// Positioning must always be specified to keep the
310-
// current child on top of the leaving children
311-
style: this.transitioningKeys[currentKey] ? positionAbsolute : {position: 'relative'},
311+
// While there are leaving children positioning must always be specified to keep the current
312+
// child on top; the current child can switch to relative positioning after entering though.
313+
style: this.transitioningKeys[currentKey]
314+
? positionAbsolute
315+
: (transitioning ? {position: 'relative'} : null),
312316
},
313317
this.wrapChild(
314318
currentChild,

0 commit comments

Comments
 (0)