question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

keepAtBottom doesn't work if the size of the inner element doesn't change

See original GitHub issue

Scenario: I have a chatcomponent that shows only the latest 50 chats in a conversation. If all my chat lines have the same height and a new line is added (which causes the previous line 0 to disappear and adds a new line on index 49), the component doesn’t scroll down.

I’ve tried editing this line so that it compares this.props.children with prevProps.children, but doesn’t always work because for some reason the reachedBottomOnCurrentRender evaluates to false…

Any idea?

Currently I just copied your code and removed the reachedBottomOnCurrentRender which still makes the component behave as expected, so not sure what the use of that check is?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Neglexiscommented, Nov 10, 2017

@rommguy Consider it done!

1reaction
rommguycommented, Nov 8, 2017

@Neglexis Thanks for showing me this bug. The fix is in version 2.0.2 I’ve added a failing test, you are welcome to review it.

I used your code to fix the issue with one change - I think comparing props.children isn’t the best way to check what we need - if the render is a result of an external change or not. Someone could cache the props from outside, and pass the same reference to them, and this will fail. Instead I created a variable called “externalRender”, assigned true in willReceiveProps (only invoked when render is caused by external action), and assigned false at the end of didUpdate This way I can enforce the bottom position as long as the render is a result of an external change, regardless of size changes in the content.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Transform scale keeps the original space around the scaled ...
The outer div fits it's width to the inner's width only if the inner div is transform: scale(1) but not using an scale...
Read more >
CSS- Div- Be Careful When You Size Your Divs
Place both DIVs into a container DIV that's set to 100% of page height and set both interior DIVS to 100%. They will...
Read more >
CSS Z-Index Not Working? How to Fix It Using Stack Order
The z-index property of CSS is a tricky one. It won't work easily by itself if you don't know how to use it...
Read more >
Editor X: Setting the Size of Your Element - Wix Help Center
Using the options in the Inspector panel, you can set your element's size exactly how you want it. Enter fixed width and height...
Read more >
CSS absolute and fixed positioning - W3C Wiki
Fixed positioning is really just a specialized form of absolute positioning; elements with fixed positioning are fixed relative to the viewport/browser window ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found