keepAtBottom doesn't work if the size of the inner element doesn't change
See original GitHub issueScenario: 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:
- Created 6 years ago
- Comments:14 (8 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@rommguy Consider it done!
@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.