rails / sdoc

Standalone sdoc generator
http://api.rubyonrails.org/
Other
820 stars 131 forks source link

Fix search results initial scroll position #337

Closed jonathanhefner closed 11 months ago

jonathanhefner commented 11 months ago

When search results are rendered, the result cursor is set to the first result and is scrolled into view via scrollIntoView({block: "nearest"}). Typically, this call to scrollIntoView would be a no-op. However, 6eb2e4293638034ce078449510867a537aff7f03 added a "TIP" at the top of the results container. Thus if the results container has max-height: 0, the scrollIntoView call will set the scroll position below the "TIP". Such is the case when clicking a .query-button or using the ?q= URL param, because the .active class is not yet applied to the results container.

This commit modifies the CSS so that the "TIP" is only shown when the .active class is applied. Thus the scrollIntoView call will remain a no-op even when the results container has max-height: 0.