eambutu / empires

3 stars 0 forks source link

chat doesnt scroll upon return to homepage #90

Open aveni opened 5 years ago

aveni commented 5 years ago

After tutorial or an FFA match, when you return to hompage / Q, the chat doesn't scroll to bottom

aveni commented 5 years ago

@a-lchen I think this is actually a bit tricky.. i cant call this.scrollChat() in the callback to the homepage because its searching for a document element that isnt there yet (the chat hasnt been rendered). I wonder if it would be better to make Chat a component and then call scroll anytime the component is mounted?

a-lchen commented 5 years ago

Can't we call it on render?

stevenhao commented 5 years ago

I suggest using refs (read discussion at https://reactjs.org/docs/refs-and-the-dom.html#exposing-dom-refs-to-parent-components if you want to manage it from the parent component, which shouldn't be necessary), instead of using document.getElementByID to access the message-feed element.

I think you should could call scrollChat whenever the Chat's messages update. This can be implemented by making Chat a class component, and using

a-lchen commented 5 years ago

That sounds promising.