coralproject / talk

A better commenting experience from Vox Media
https://coralproject.net
Other
1.89k stars 355 forks source link

Adding unnecessary padding when trying to render commenting thread in a modal #4510

Closed SadhuSantosh closed 7 months ago

SadhuSantosh commented 7 months ago

Expected behavior: Need to render without adding unnecessary padding.

Actual behavior: Adding padding below the commenting thread when we have load more button and padding-top after clicking on load more. image

Steps to reproduce: 1) visit staging site 2) scroll down until you see a comments button. 3) click the comments button which opens a commenting thread in a modal. 4) scroll down to the thread you can see the padding below and then load more button.

This is working fine without having any padding above or below if I add it to the flow article flow but when I try to add it inside a Modal then this issue is happening.

Versions: v7.5.0

oliver-dvorski commented 7 months ago

https://github.com/coralproject/talk/issues/4375

https://github.com/coralproject/talk/pull/4389

kabeaty commented 7 months ago

Hello @SadhuSantosh, Thank you for reaching out with this. I would recommend passing the customScrollContainer option through to Coral when creating the comment stream embed. The customScrollContainer supports a custom HTML element as a scroll container if Coral is rendered outside of the render window. So, in this case, you'd want to pass through an HTML element that contains Coral within the modal. This solution has resolved similar issues when we've encountered them before. See https://github.com/coralproject/talk/blob/develop/client/src/core/client/embed/Coral.ts#L41

SadhuSantosh commented 7 months ago

@kabeaty Thanks for the inputs, Can you share any code snippet that would help me move forward?

kabeaty commented 7 months ago

To pass through a custom scroll container, get the HTML element that contains Coral within the modal that you want to use and pass it through when you create the stream embed. So, something like this wherever you are already creating the stream embed:

Coral.createStreamEmbed({
  // other arguments already passed through here
  customScrollContainer: document.getElementById("INSERT_ID_OF_SCROLL_CONTAINER_ELEMENT");
});

Hope this helps!

losowsky commented 7 months ago

@SadhuSantosh @oliver-dvorski Since Kathryn responded above with a solution, I'm going to close this ticket. Let us know if you have any other issues!