diff --git a/docs/src/examples/modules/Sticky/Usage/StickyExampleAboveContent.js b/docs/src/examples/modules/Sticky/Usage/StickyExampleAboveContent.js
new file mode 100644
index 0000000000..27036a3290
--- /dev/null
+++ b/docs/src/examples/modules/Sticky/Usage/StickyExampleAboveContent.js
@@ -0,0 +1,36 @@
+import React, { Component, createRef } from 'react'
+import { Image, Input, Menu, Segment, Sticky } from 'semantic-ui-react'
+import _ from 'lodash'
+
+export default class StickyExampleAboveContent extends Component {
+ contextRef = createRef()
+
+ render() {
+ return (
+
+
+
+
+
+ {_.times(5, i => )}
+
+
+ )
+ }
+}
diff --git a/docs/src/examples/modules/Sticky/Usage/index.js b/docs/src/examples/modules/Sticky/Usage/index.js
index aa1cf585d3..73b25ba569 100644
--- a/docs/src/examples/modules/Sticky/Usage/index.js
+++ b/docs/src/examples/modules/Sticky/Usage/index.js
@@ -10,6 +10,11 @@ const StickyUsageExamples = () => (
description='Define the offset from the top/bottom of the screen when fixing element to viewport.'
examplePath='modules/Sticky/Usage/StickyExampleOffset'
/>
+
)
diff --git a/src/modules/Sticky/Sticky.js b/src/modules/Sticky/Sticky.js
index e3bdfc8d76..17acfca811 100644
--- a/src/modules/Sticky/Sticky.js
+++ b/src/modules/Sticky/Sticky.js
@@ -4,8 +4,8 @@ import PropTypes from 'prop-types'
import React, { Component, createRef } from 'react'
import {
- eventStack,
customPropTypes,
+ eventStack,
getElementType,
getUnhandledProps,
isBrowser,
@@ -316,10 +316,11 @@ export default class Sticky extends Component {
sticky && !bound && (bottom === null ? 'top' : 'bottom'),
'sticky',
)
+ const triggerStyles = sticky && this.stickyRect ? { height: this.stickyRect.height } : {}
return (
-
+
{children}
diff --git a/test/specs/modules/Sticky/Sticky-test.js b/test/specs/modules/Sticky/Sticky-test.js
index 15931c4405..7d4f830ae2 100644
--- a/test/specs/modules/Sticky/Sticky-test.js
+++ b/test/specs/modules/Sticky/Sticky-test.js
@@ -199,6 +199,20 @@ describe('Sticky', () => {
.childAt(1)
.should.have.style('bottom', '0px')
})
+
+ it('should preserve sticky element height', () => {
+ mockContextEl()
+ mockPositions({ bottomOffset: 0, height: 100, offset: 0 })
+ wrapperMount()
+
+ // Scroll after trigger
+ scrollAfterTrigger()
+
+ wrapper
+ .childAt(0)
+ .childAt(0)
+ .should.have.style('height', '100px')
+ })
})
describe('onBottom', () => {
it('is called with (e, data) when is on bottom', () => {