Scroll to component inside reusable component

I have a page with several reusable components on it. some are quite large.

I know I can scroll to a component on my page and thus can scroll to a reusable component. However, is it possible to scroll to a component that is inside the reusable component? The component IDs for things inside reusable components are not listed in the list of available objects in the getComponentById block.

Hello @James_Hereford

If you have a way to access the needed component, like store it somewhere, or return from some function - then yes.

Otherwise, you always could use a Custom Code and document.querySelector(<>) function - where <> is some class or id of the element that you looking for, and which returns an element that you could pass into a scroll block.

Thanks Dima. Any chance you could give an example of scrolling to a component inside a reusable component using it’s ID? I am not sure I follow how to use the document.querySelector function.

Let’s say I have a reusable component called, “reusableComponent”. Inside it has an input field with ID, “inputField1”. I would like to scroll to “inputField1”

Thanks!

Hello @James_Hereford

You can implement this through a custom code block.

return { el: document.querySelector(`.${ elementClassName }`) }

Regards

Awesome, thanks for the example Viktor. This helps a lot!