Skip to content

Commit

Permalink
Fix search results initial scroll position
Browse files Browse the repository at this point in the history
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,
6eb2e42 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`.
  • Loading branch information
jonathanhefner committed Oct 18, 2023
1 parent 8997512 commit 8dd6674
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/rdoc/generator/template/rails/resources/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,9 @@ html {
font-size: 0.9em;
font-style: italic;
color: color-mix(in srgb, currentColor 70%, transparent);
}

.panel__results.active::before {
content: "TIP: Prefix query with \"#\" or \".\" to search for methods.";
}

Expand Down

0 comments on commit 8dd6674

Please sign in to comment.