Hi everyone,
I am following up on a question from @neelsarode during the office hours on October 17, 2023. The question was about how to properly initialize a long list of comments in a side popup so that users don’t have to scroll to see the last message.
- First, let’s quickly create a side popup with a scrollable list.
- A variable will be added to manage the display of the popup.
- Add a button and create workflow. In the workflow add an action to change the value of the variable
show
to true. Test the button.
- Add some content to the popup. I used the ready-made feed element from the
add
panel.
- Add more objects to the
feed
variable.
[{"name":"Joshua Steiner","time":"Just now","handle":"jsteiner","comment":"Can we get some feedback on this?"},{"name":"Lana Steiner","time":"2 minutes ago","handle":"jsteiner","comment":"Sure, will take a look this afternoon."},{"name":"Elizabeth Clarke","time":"2 minutes ago","handle":"eclarke","comment":"Thanks for the comments. Will get to them very shortly."},{"name":"Lisa Wu","time":"10 minutes ago","handle":"lwu","comment":"Great work everyone, keep it up!"},{"name":"Joshua Steiner","time":"Just now","handle":"jsteiner","comment":"Can we get some feedback on this?"},{"name":"Lana Steiner","time":"2 minutes ago","handle":"jsteiner","comment":"Sure, will take a look this afternoon."},{"name":"Elizabeth Clarke","time":"2 minutes ago","handle":"eclarke","comment":"Thanks for the comments. Will get to them very shortly."},{"name":"Lisa Wu","time":"10 minutes ago","handle":"lwu","comment":"Great work everyone, keep it up!"},{"name":"Joshua Steiner","time":"Just now","handle":"jsteiner","comment":"Can we get some feedback on this?"},{"name":"Lana Steiner","time":"2 minutes ago","handle":"jsteiner","comment":"Sure, will take a look this afternoon."},{"name":"Elizabeth Clarke","time":"2 minutes ago","handle":"eclarke","comment":"Thanks for the comments. Will get to them very shortly."},{"name":"Lisa Wu","time":"10 minutes ago","handle":"lwu","comment":"Great work everyone, keep it up!"}]
- Add a fixed high to the container. A good practice is to use
calc(100vh - xxxpx)
so the height will always be 100% of the screen height minus some pixels you specify by replacing xxx by a number. Like this
- Then, on the container again, change the overflow value to
scroll
. Now you can scroll the content in the container.
- Add a div at the end of the container. Set a height to 0px. Go to the settings tab and add an id:
end-of-container
- Then, go back to the workflow on the button that opens the modal. Add a new action
custom javascript
and paste this code:
const target = wwLib.getFrontDocument().querySelector("#end-of-container")
target.scrollIntoView({behavior:"smooth", block: "start",inline: "nearest"});
Here you are:
More details of scrollIntoView function here.
I hope you like it. Tell us if it works for you.
Cheers.